I was using rails 4.1.7 with ruby 2.0.0 and have developed an application.
Recently upgraded to ruby 2.1.4 and made that as "Local" setting using rbenv. Now after doing "gem install rails", everything installed well.
Question is now if I try to run server, i am getting error
"Could not find rake-10.4.0 in any of the sources
Run bundle install to install missing gems."
bundle show rake reveals that its installed under
"bundle show rake
/Library/Ruby/Gems/2.0.0/gems/rake-10.4.0"
Shouldn't this be under 2.1.4?
Use rvm or rbenv to change ruby and gem space to another one. If you will begin usage of the them do the following (NOTE: If you already use one of them, just begin with point 2):
Install rvm with ruby:
$ \curl -sSL https://get.rvm.io | bash -s stable --ruby
or install rbenv, and then install ruby, and make it global:
$ \curl https://raw.githubusercontent.com/fesplugas/rbenv-installer/master/bin/rbenv-installer | bash
$ rbenv install 2.1.4
$ rbenv global 2.1.4
Enter to the project, create two files .ruby-version with just installed version of ruby (in example 2.1.4), and .ruby-gemset with name of your project:
$ cd project-folder
$ echo "2.1.4" > .ruby-version
$ echo "your-project-name" .ruby-gemset
Fix Gemfile with newly intsalled version of ruby adding a line:
ruby '2.1.4'
Reenter to the project folder, and rvm will generate its wrappers:
$ cd .. ; cd project-folder
Issue gem installation:
$ bundle install
Related
I am trying to learn Ruby on Rails, I have installed Ruby, ruby -v gives ruby 2.7.0p0 (2019-12-25 revision 647ee6f091) [x86_64-darwin18] and I have installed rails using gem install rails however when I run rails -v I get the following dialogue.
Rails is not currently installed on this system. To get the latest version, simply type:
$ sudo gem install rails
You can then rerun your "rails" command.
I then do as the prompt asks and run sudo gem install rails (inputting my pw) which gives me;
Successfully installed rails-6.0.2.2
Parsing documentation for rails-6.0.2.2
Done installing documentation for rails after 0 seconds
1 gem installed
to check that Rails has installed properly I run rails -v again, and again I get;
Rails is not currently installed on this system. To get the latest version, simply type:
$ sudo gem install rails
You can then rerun your "rails" command.
Am I missing something very obvious?
The best way to manage your Ruby/Rails environment is to use a tool like rvm and never use the system Ruby/Rails. Changing Ruby/Rails versions globally for all your apps will most likely break them, so you want each app to be locked to a specific Ruby/Rails version and only upgrade each one manually.
Start by installing RVM locally for your user:
\curl -sSL https://get.rvm.io | bash -s stable --ruby
echo "source $HOME/.rvm/scripts/rvm" >> ~/.bash_profile
source $HOME/.rvm/scripts/rvm
Make a directory for your app.
mkdir my_rails_app && cd my_rails_app
Make a local .ruby-version and .ruby-gemset for each project:
echo 2.6.5 > .ruby-version
echo my_rails_app > .ruby-gemset
rvm reload
Then install rails only for the specific gemset "my_rails_app" (I usually give each app its own gemset).
gem install rails
rails new my_rails_app .
I am trying to install gems for a new Rails project using bundler:
$ bundle install --path
I've set my local Ruby version to 2.3.1 using rbenv, but bundler is still using my system Ruby (2.0.0).
$ rbenv local
2.3.1
$ echo $PATH
/Users/jenniferpierce/.rbenv/shims:/Users/jenniferpierce/.rbenv/bin:/usr/local/bin:/usr/bin:/bin:/usr/sbin:/sbin:/Library/PostgreSQL/9.5/bin
$ which ruby
/Users/jenniferpierce/.rbenv/shims/ruby
$ ruby -v
ruby 2.3.1p112 (2016-04-26 revision 54768) [x86_64-darwin15]
$ bundle install --path
Your Ruby version is 2.0.0, but your Gemfile specified 2.3.1
My bash profile includes:
export PATH="$HOME/.rbenv/bin:$PATH"
eval "$(rbenv init -)"
I've run:
$ rbenv rehash
and restarted my terminal. Maybe I'm missing something super obvious? Any ideas would be appreciated.
To add to this, in my case, I first had to run rbenv rehash and then install the bundler gem, and then re-run bundle install. Without all of those steps, it kept the same old Ruby version.
You should be able to just run bundle install without the --path. I believe --path allows you to specify a different path than the one in your system, but if you modified your bash profile as you suggested, there is no need for that.
Also, if you just changed your ruby version for the local folder, you should run a gem install bundler.
I have recently moved from RVM to Rbenv and when attempting to execute rails I am getting an error like the one below
Pauls-Air:~ $ rails
rbenv: rails: command not found
The `rails' command exists in these Ruby versions:
2.1.2
After installing a gem via the command line in a ruby version you have to execute rbenv rehash as described in the docs here and here
For example:
$ rbenv install 2.2.0
$ gem install bundler
$ rbenv rehash
$ gem install rails
$ rbenv rehash
You need to install Rails for each Ruby version within rbenv. Try running rbenv version, I might expect that 2.1.2 is not the ruby version in use for the current project (local version) or maybe your global version.
I ran into the same issue, but none of these other solutions (or any of the others I found elsewhere) worked. I was about to go back to RVM, so I decided to get rid of rbenv completely and it paved the way to the solution.
Try the following - it worked for me:
uninstalling rbenv, remove all references rbenv in your bash profile, and remove the remaining rbenv file folder and its contents.
Reinstall rbenv with homebrew.
Add it back to your bash profile:
export PATH="$HOME/.rbenv/bin:/usr/local/bin:$PATH"
eval "$(rbenv init -)"
Restart the shell:
exec $SHELL -l
Check the path:
echo $PATH
Install Rails:
gem install rails
rbenv rehash
Note: I consulted this for part of this answer: https://www.codementor.io/tips/3732499178/solution-for-rbenv-rails-is-not-currently-installed-on-this-system-to-get-the-latest-version-simply-type
Try to set up your environment with 2.1.2 version running this command line in your terminal:
$ rbenv shell 2.1.2
It works to me
Ensure that the .ruby-version file in your project's directory contains the same ruby version as the one you installed with rbenv.
For me, I set up my environment with the listed "The `rails' command exists in these Ruby versions".
$ rbenv shell 2.1.2
$ rails -v
It works.
Like for example if you want to install Ruby 2.5.3 with Rails 6
follow this way:-rbenv global 2.5.3
$ gem update --system
$ rbenv install 2.5.3
$ rbenv global 2.5.3
$ gem install rails -v 6.0.2.2
$ ruby -v
$ rails -v
The problem is that your global ruby version doesn't match your installed somewhere locally version which is 2.1.2. Try executing anywhere in bash shell:
rbenv global 2.1.2
That way rails will be found by rbenv in your $HOME directory and anywhere else.
rbenv global
Sets the global version of Ruby to be used in all shells by writing
the version name to the ~/.rbenv/version file. This version can be
overridden by an application-specific .ruby-version file, or by
setting the RBENV_VERSION environment variable.
I have setup Radrails on my linux machine. I dont have root privileges on this machine and I also cant edit the ruby installation folder. I have set GEM_HOME and GEM_PATH to a location where I have privileges. I am running radrails from the terminal where I have set these variables. Does Radrails is recognize the gem location?
Also I am not able to start the Webrick server using Radrails. The server always is in stopped state and the console output is blank. I am not able to fix this since I dont see any errors.
thank you!
Use rvm or rbenv to change ruby and gem space to another one. If you will begin usage of the them do the following:
Install rvm with ruby:
$ \curl -sSL https://get.rvm.io | bash -s stable --ruby
or install rbenv, and then install ruby, and make it global:
$ \curl https://raw.githubusercontent.com/fesplugas/rbenv-installer/master/bin/rbenv-installer | bash
$ rbenv install 2.1.4
$ rbenv global 2.1.4
Install the rails without documentation into the general gem space:
$ gem install rails --no-ri --no-rdoc
Enter to the project, create two files .ruby-version with just installed version of ruby (in example 2.1.4), and .ruby-gemset with name of your project:
$ cd project-folder
$ echo "2.1.4" > .ruby-version
$ echo "your-project-name" .ruby-gemset
Fix Gemfile with newly intsalled version of ruby adding a line:
ruby '2.1.4'
Reenter to the project folder, and rvm will generate its wrappers:
$ cd .. ; cd project-folder
Issue gem installation:
$ bundle install
I had used below mentioned commands to install rails in ubuntu 12.10
sudo apt-get update
sudo apt-get install curl
\curl -L https://get.rvm.io | bash -s stable
source ~/.rvm/scripts/rvm
rvm requirements
rvm install 1.9.3
rvm use 1.9.3 --default
rvm rubygems current
gem install rails
Every steps are doing good, but it works for terminal which we are installing rails. If we exit from the terminal and work on a new terminal then the following error occurs.
The program 'rails' can be found in the following packages: * rails * ruby-railties-3.2 Try: sudo apt-get install
I came through a solution that whenever I open an terminal I would run these cmd
source ~/.rvm/scripts/rvm rvm --default use 1.9.3-p374
Can any one explain why these things happen??
Did you include the init script into your bash_profile/bashrc?
RVM installed by Ruby not working?
I've installed Rails 3.2.9 on my machine with RVM. You can follow this steps:
Install RVM : \curl -L https://get.rvm.io | bash -s stable
Reload shell configuration & test: source ~/.rvm/scripts/rvm
Install Ruby via RVM: rvm install 1.9.2 or rvm install 1.9.3
Choose version Ruby after install: rvm use 1.9.2 or rvm use 1.9.3
Ruby 1.9.2 and 1.9.3 support gem 1.8.25, so you'll install rails: gem install rails -v 3.2.9.
Done.
Note
Reload shell: source ~/.rvm/scripts/rvm and choose version Ruby rvm use 1.9.2 before work with projects.