I've installed Ruby and Rails, and for the most part it's installed. However, when I try to create an app to see if all the installations work, the rails server won't run. It goes something like this:
I created a new rails app file, it's shown in my C: directory so that's a success
but the last line at the installation said this:
bundle install
The latest bundler is 2.3.10, but you are currently running 1.15.3.
To update, run `gem install bundler`
Fetching source index from https://rubygems.org/"
I tried the
gem install bundler
next, but I got this error message:
ERROR: Could not find a valid gem 'bundler' (>= 0), here is why:
Unable to download data from https://rubygems.org/ - SSL_connect returned=1 errno=0 state=error: certificate verify failed (https://api.rubygems.org/specs.4.8.gz)
also when I tried,
rails s
I got this result:
Usage:
rails new APP_PATH [options]
Options:
-r, [--ruby=PATH] # Path to the Ruby binary of your choice
# Default: C:/RailsInstaller/Ruby2.3.3/bin/ruby.exe
-m, [--template=TEMPLATE] # Path to some application template (can be a filesystem path or URL)
-d, [--database=DATABASE] # Preconfigure for selected database (options: mysql/postgresql/sqlite3/oracle/frontbase/ibm_db/sqlserver/jdbcmysql/jdbcsqlite3/jdbcpostgresql/jdbc)
# Default: sqlite3
[--skip-yarn], [--no-skip-yarn] # Don't use Yarn for managing JavaScript dependencies
[--skip-gemfile], [--no-skip-gemfile] # Don't create a Gemfile
-G, [--skip-git], [--no-skip-git] # Skip .gitignore file
[--skip-keeps], [--no-skip-keeps] # Skip source control .keep files
-M, [--skip-action-mailer], [--no-skip-action-mailer] # Skip Action Mailer files
-O, [--skip-active-record], [--no-skip-active-record] # Skip Active Record files
-P, [--skip-puma], [--no-skip-puma] # Skip Puma related files
-C, [--skip-action-cable], [--no-skip-action-cable] # Skip Action Cable files
-S, [--skip-sprockets], [--no-skip-sprockets] # Skip Sprockets files
[--skip-spring], [--no-skip-spring] # Don't install Spring application preloader
[--skip-listen], [--no-skip-listen] # Don't generate configuration that depends on the listen gem
[--skip-coffee], [--no-skip-coffee] # Don't use CoffeeScript
-J, [--skip-javascript], [--no-skip-javascript] # Skip JavaScript files
[--skip-turbolinks], [--no-skip-turbolinks] # Skip turbolinks gem
-T, [--skip-test], [--no-skip-test] # Skip test files
[--skip-system-test], [--no-skip-system-test] # Skip system test files
[--dev], [--no-dev] # Setup the application with Gemfile pointing to your Rails checkout
[--edge], [--no-edge] # Setup the application with Gemfile pointing to Rails repository
[--rc=RC] # Path to file containing extra configuration options for rails command
[--no-rc], [--no-no-rc] # Skip loading of extra configuration options from .railsrc file
[--api], [--no-api] # Preconfigure smaller stack for API only apps
-B, [--skip-bundle], [--no-skip-bundle] # Don't run bundle install
[--webpack=WEBPACK] # Preconfigure for app-like JavaScript with Webpack (options: react/vue/angular)
Runtime options:
-f, [--force] # Overwrite files that already exist
-p, [--pretend], [--no-pretend] # Run but do not make any changes
-q, [--quiet], [--no-quiet] # Suppress status output
-s, [--skip], [--no-skip] # Skip files that already exist
Rails options:
-h, [--help], [--no-help] # Show this help message and quit
-v, [--version], [--no-version] # Show Rails version number and quit
Description:
The 'rails new' command creates a new Rails application with a default
directory structure and configuration at the path you specify.
You can specify extra command-line arguments to be used every time
'rails new' runs in the .railsrc configuration file in your home directory.
Note that the arguments specified in the .railsrc file don't affect the
defaults values shown above in this help message.
Example:rails new ~/Code/Ruby/weblog
This generates a skeletal Rails installation in ~/Code/Ruby/weblog.
I have tried to install bundler, update bundler, update system... none of that worked. I've also tried the cacert.pem file for certification (according to one of the tutorial articles I found), but it's still doesn't work.
I'm using Windows 10, ruby 2.3.3p222 and Rails 5.1.3. With this, do I need to reinstall Ruby and Rails? Is there something missing in my installation?
Related
How to save the default editor in .gemrc so that I can skip providing the editor with the following command:
gem open GEMNAME [-e EDITOR] [options]
1) Using a .gemrc file:
GEM ENVIRONMENT
...
...
The RubyGems environment can be controlled through command line
arguments, gemrc files, environment variables and built-in defaults.
Command line argument defaults and some RubyGems defaults can be set
in a ~/.gemrc file for individual users and a gemrc in the SYSTEM
CONFIGURATION DIRECTORY for all users. These files are YAML files with
the following YAML keys:
:sources: A YAML array of remote gem repositories to install gems from
:verbose: Verbosity of the gem command. false, true, and :really are the
levels
:update_sources: Enable/disable automatic updating of repository metadata
:backtrace: Print backtrace when RubyGems encounters an error
:gempath: The paths in which to look for gems
:disable_default_gem_server: Force specification of gem server host on push
<gem_command>: A string containing arguments for the specified gem command
http://guides.rubygems.org/command-reference/#gem-environment
Note the last line. For example, if I put the following in ~/.gemrc:
open: -e /Users/7stud/Downloads/macvim-snapshot-74/src/MacVim/mvim
then the command:
$ gem open nokogiri
will open nokogiri in macvim on my system.
2) Using environment variables(per mash's comment):
GEM OPEN
...
...
The open command opens gem in editor and changes current path
to gem's source directory. Editor can be specified with -e option,
otherwise rubygems will look for editor in $EDITOR, $VISUAL and
$GEM_EDITOR variables.
http://guides.rubygems.org/command-reference/
That means if I put something like the following in .bash_profile (or .bashrc):
export GEM_EDITOR="/Users/7stud/Downloads/macvim-snapshot-74/src/MacVim/mvim"
then the command:
$ gem open nokogiri
will open nokogiri in macvim on my system. Don't forget to open a new Terminal window or issue the command:
$ source .bash_profile
to load the changes you made to the environment variables in .bash_profile.
I am trying install devkit on windows 7 but getting below error while issuing command
ruby dk.rb install.
[INFO] Skipping existing gem override for 'C:/RailsInstaller/Ruby1.9.3'
[WARN] Skipping existing DevKit helper library for 'C:/RailsInstaller/Ruby1.9.3'
So i tried >ruby dk.rb install --force but now i am getting this error,
[WARN] Updating (with backup) existing gem override for 'C:/RailsInstaller/Ruby1
.9.3'
[WARN] Updating (with backup) DevKit helper library for 'C:/RailsInstaller/Ruby1
.9.3'
I have installed ruby using rails installer.
This is the content in my config.yml file,
# This configuration file contains the absolute path locations of all
# installed Rubies to be enhanced to work with the DevKit. This config
# file is generated by the 'ruby dk.rb init' step and may be modified
# before running the 'ruby dk.rb install' step. To include any installed
# Rubies that were not automagically discovered, simply add a line below
# the triple hyphens with the absolute path to the Ruby root directory.
#
# Example:
#
# ---
# - C:/ruby19trunk
# - C:/ruby192dev
#
---
- C:\RailsInstaller\Ruby1.9.3
Is just a warning, ignore it, don't --force it, use Ruby and live long and prosper.
I'm trying to set up my own private gem server which should serve my gems and display the rdoc. As I've read the default gem server should be able to do that. And since I do not want all gems except my own to be displyed on the gem server I'm doing the following:
gem install -i /some/dir --ignore-dependencies my-special.gem
gem server -d /some/dir # -d should let me set my gem dir
But first of all, the gem server still displays all installed system gems and does not display what's inside some/dir. And second, when trying to do a:
gem install --source http://localhost:8808 my-special.gem
I only get the following messsage:
ERROR: Could not find a valid gem 'my-special' (>= 0) in any repository
ERROR: While executing gem ... (Gem::RemoteFetcher::FetchError)
bad response Gateway Time-out 504 (http://localhost:8808/latest_specs.4.8.gz)
And I get that even for the gems that get displayed on the created gem server page at
http://localhost:8808
What am I doing wrong? Some blogs mention to update the index with gem generate_index but this makes no sense since this tool expects the *.gem files to be in a /gems subdir but by default they land in /cache.
I solved this pretty easily.
I don't even use a dedicated gem server.
I did the following:
Create a directory on your apache web server that is servable and create a gems subdir in it. For example:
mkdir -p /var/www/rubygems/gems
Put all gems you want to serve to the created gems subdirectory: cp /my/gems/dir/*.gem /var/www/rubygems/gems
Generate the gem index:
gem generate_index -d /var/www/rubygems
Do not forget to adapt the access rights so that your web server can read the contents
INFO: The index has to be generated in the directory that contains the gems subdir, not the gems dir itself! In this case it's /var/www/rubygems.
Now you can add http://<my-gem-server>.domain/rubygems to your gem sources
It is always frustrating to install a gem and wait 2 seconds for the gem to install and then wait 30 seconds for the docs, which I never use(Google, anyone?). Why do we force this convention upon ourselves when the local docs normally aren't even beneficial?
I know you can use gem install rails --no-ri --no-rdoc to skip that step but is there a way to simply skip the docs by default?
Add the flags to your ~/.gemrc file.
From the docs:
gem looks for a configuration file .gemrc in your home directory,
although you can specify another file on the command-line if you wish
(with the --config-file modifier). Only one configuration file will be
processed: the rightmost one on the command-line, or the default
$HOME/.gemrc, or none at all.
There are three things you can specify in the configuration file:
command-line arguments to be used every time gem runs
command-line options for "RDoc" (used when generating documentation)
GEMPATH settings
The config file itself is in "YAML" format. Here is an example:
gem: --local --gen-rdoc --run-tests
rdoc: --inline-source --line-numbers
gempath:
- /usr/local/rubygems
- /home/gavin/.rubygems
The effects of such a config file would be:
gem only runs "local" operations (unless you specify --remote or --both on the command-line)
gem generates RDocs and runs unit tests every time it installs something (good idea!)
when it generates RDocs, the given arguments will be used
/usr/local/rubygems and /home/gavin/rubygems will be used as your $GEM_PATH setting
I want to create some Gems with parameters lists when i run: my_app --help.
Just like all the gems (rake, rails etc).
Example:
Usage:
rails new APP_PATH [options]
Options:
-J, [--skip-prototype] # Skip Prototype files
-T, [--skip-test-unit] # Skip Test::Unit files
[--dev] # Setup the application with Gemfile pointing to your Rails checkout
-G, [--skip-git] # Skip Git ignores and keeps
-b, [--builder=BUILDER] # Path to an application builder (can be a filesystem path or URL)
-m, [--template=TEMPLATE] # Path to an application template (can be a filesystem path or URL)
[--edge] # Setup the application with Gemfile pointing to Rails repository
[--skip-gemfile] # Don't create a Gemfile
-d, [--database=DATABASE] # Preconfigure for selected database (options:
In this way I could just use it by:
gem install my_gem
my_gem --help
my_gem delete files file1.jpg file2.jpg
my_gem update
etc...
Is there some kind of gem framework for this or does one have to start from scratch?
There's a lot of options (haaaa...)
A standard one is in Ruby's stdlib: http://ruby-doc.org/stdlib/libdoc/optparse/rdoc/index.html
Rails uses Thor, which might suit your needs better. http://rubygems.org/gems/thor