I have been learning Ruby on Rails for a couple of months, and everything was working.
Then, for the needs of a tutorial, I tried to install RVM, in order to downgrade my setup to older versions of Ruby and Rails.
And since then, I kept running into troubles.
For instance, anytime I launch a new Terminal session, here is what I get:
You are using '.rvmrc', it requires trusting, it is slower and it is not compatible with other ruby managers,
you can switch to '.ruby-version' using 'rvm rvmrc to [.]ruby-version'
or ignore this warning with 'rvm rvmrc warning ignore /Users/Thibaud/work/.rvmrc',
'.rvmrc' will continue to be the default project file in RVM 1 and RVM 2,
to ignore the warning for all files run 'rvm rvmrc warning ignore all.rvmrcs'.
ree-1.8.7-2012.02 - #gemset created /Users/Thibaud/.rvm/gems/ree-1.8.7-2012.02#tedxperth
ree-1.8.7-2012.02 - #generating tedxperth wrappers....................
Using /Users/Thibaud/.rvm/gems/ree-1.8.7-2012.02 with gemset tedxperth
Warning! Executable 'ruby' missing, something went wrong with this ruby installation!
Warning! Executable 'gem' missing, something went wrong with this ruby installation!
Warning! Executable 'irb' missing, something went wrong with this ruby installation!
Two questions:
How can I resolve the errors appearing in my Terminal? (see above)
Since I do not know what got broken in my install, I am wondering whether I should unsintall the whole Ruby on Rails environment and set it up again to get a clean install: Is this a good idea? If so, how can it be achieved?
Your first set of errors will go away if your remove the hidden .rvmrc file in your project directory:
$ rm .rvmrc
The file only exists to set a Ruby version and gemset when you cd into the directory. You can either set the Ruby version and gemset manually, or create new .ruby-version and .ruby-gemset files which are compatible with RVM and other version managers. For details, see my answer Use rvmrc or ruby-version file to set a project gemset with RVM?.
You may need to remove and reinstall the Ruby version you are using. Here's how:
$ rvm remove ree-1.8.7-2012.02
Here's the documentation.
You probably don't need to uninstall RVM. But if you do, you can use
$ rvm implode
to remove all traces of RVM before re-installing (documented here). For more details on installing Ruby and multiple versions of Rails using RVM, see the article I wrote:
Install Ruby on Rails - Mac OS
X
Lastly, since you mention that you are reading a tutorial that requires an old version of Rails, may I politely suggest you have a look at a book I've written for beginners that is up to date with the newest version of Rails (currently Rails 4.1 but I revise the book with every new release). I hope it is helpful:
Learn Ruby on
Rails
I mention my article and my book because they provide additional information about setting your development environment for Rails using RVM and may answer further questions for you.
Related
I removed the previous version of ruby I installed, ruby 1.9.1 to be precise, on my Ubuntu, and installed version 2.2.3. When I try to run bundle install on my terminal, I get this error
bash: /usr/local/bin/bundle: /usr/bin/ruby1.9.1: bad interpreter: No such file or directory.
Can anyone advice on how to fix it?
How did you remove the old version of Ruby?
It looks like it left the binary executable for bundler, so I'm guessing you just straight up deleted the usr/bin/ruby folder? Ruby installations (and most installations) tend to create executable binaries in other folders that need to be deleted as well.
I would highly recommend that you use something like rvm or rbenv to manage multiple versions of ruby on your system. Those tools are designed to do that sort of thing and are basically industry standard at this point.
My personal recommendation is rvm, although either is really fine. If you choose to go with that, check out rvm.io for installation instructions.
It'll install rvm with the latest ruby version. In addition to that you are free to install any other version of ruby or patch that you prefer, and you can easily switch between the two using rvm use <ruby version>
When I execute the command:
rails s in my project, the console display the message:
Your Ruby version is 2.0.0, but your Gemfile specified 2.1.2
I executed the command:
brew upgrade rbenv ruby-build
rbenv install --list
and the version 2.1.2 appears in the list.
Then, I executed the command: rbenv rehash, but appears the same message when I executed the command:
rails s.
In my Gemfile file, is listed the:
ruby '2.1.2'
but I'm not looking replace this value with the previous version.
And if I execute :
rvm use 2.1.2
Is displayed:
Warning! PATH is not properly set up,
'/Users/Jarvis/.rvm/gems/ruby-2.1.2/bin' is not at first place,
usually this is caused by shell initialization files - check them for 'PATH=...' entries,
it might also help to re-add RVM to your dotfiles: 'rvm get stable --auto-dotfiles',
to fix temporarily in this shell session run: 'rvm use ruby-2.1.2'. Using /Users/Jarvis/.rvm/gems/ruby-2.1.2 Warning!
Executable 'ruby' missing, something went wrong with this ruby
installation! Warning! Executable 'gem' missing, something went wrong
with this ruby installation! Warning! Executable 'irb' missing,
something went wrong with this ruby installation!
What I'm doing wrong?
RVM and RBenv are actually similar tools. There are no practical reasons to keep them alongside each other in one session (and on one machine most of the time). They both rely on modifying PATH environment variable to get the Ruby and supplementary binaries closer for easy use.
And that's what RVM complains about: PATH is not what it expects to be. That said, RBEnv apparently tampered with it. Since these tools do their best to overtake ruby, gem, irb and stuff, they may very well conflict with each other on occasions.
So, remove one of them. Which one, is up to you. Removing RVM is as easy as:
rvm implode
...that will remove RVM's files, rubies and gems for them, but you might also want to inspect .bash_profile, .profile and .bashrc for relevant lines.
The uninstallation process for RBEnv seems to be the manual one: remove the folder, review the files listed above for relevant lines.
This is a beginner-level question.
I'm using Ubuntu 12.04
I copied a project (created on Rails 4 using the rails new command) from Dropbox to my local environment, where I have previously install Rails 4 and up-to-date Ruby and RVM, went to project's directory, typed rails server and got
The program 'rails' is currently not installed. You can install it by typing:
sudo apt-get install rails
I ran gem install rails instead.
Will I have to run gem install rails on every project's directory? I thought the Rails install was a general and accessible on my whole environment.
The project was created using the same Ruby version, but on a MacOS X system.
The project is a static web brochure and has no database configuration.
Thank you in advance.
Make sure you're using the correct version of Ruby - the same version that you'd installed Rails into - with rvm list.
You likely have two of them (since you have such an issue) - the system Ruby and the RVM-installed Ruby. And likely RVM didn't engage and hook up the correct path to the rails executable, thus the error.
This should fix the issue:
rvm use whatever-ruby-you-had-installed-rails-into
Where whatever-ruby-you-had-installed-rails-into is a string like ruby-2.1.0-p0 taken from the rvm list output.
To make RVM retain Ruby version for the project.
echo whatever-ruby-you-had-installed-into >.ruby-version
in your project's path.
So after a few hours of testing, reproducing the problem, and reading (the other answers inclusive) I got the solution as follows:
Short answer: No. Rails needs to be installed only once.
Long answer: This problem occurred because of a default setting on Terminal that prevents the system from using RVM installations of ruby and rails. The solution is to integrate RVM with gnome-terminal as described in the RVM website.
With terminal window active, go to the menu at the top bar
Edit > Profile Preferences > Title and Command tab
Check the Run command as a login shell box
Restart Terminal and make sure your gemset and ruby version are set
rails server should now work as expected (you might be prompted to run bundle install before Rails can actually run fine, follow the promtp).
I am still learning to work with Ruby on Rails, so any inputs, clarifications, or additional information on the issue is more than welcome.
You don't have to install Rails on every project, but the gems that you need for that project.
With bundle install you install all the gems that you specify in Gemfile.
If you want to avoid reinstall the gems every time you change project, I suggest you to have a better look to RVM: it has got an opt called gemset (https://rvm.io/gemsets), if you use it you just need to switch your gemset:
rvm gemset use yourgemset
I hope it can help you.
I have two servers that are running (almost) identical installs. Both servers are VMs and server_b was created as a copy of server_a (this is how I know they are identical installs). Server_a has since been updated using 'rvm get HEAD'.
server_a:
rvm version 1.15.4
ruby-1.8.7-p334
.rvmrc file specifying ruby-1.8.7#my_gemset (no patch level specified)
Rails 3.0.5
server_b:
rvm v 1.2.8
ruby-1.8.7-p334
.rvmrc file specifying ruby-1.8.7#my_gemset (no patch level specified)
Rails 3.0.5
When I deploy to server_a, RVM complains that ruby-1.8.7-p370 is not installed, but deploying to server_b does not generate this error. I'm not sure why it is looking for the latest patchlevel for 1.8.7 -- I have gone through the RVM configs on each server, comparing them. (The output from 'rvm info' results in the same information from both servers, other than the RVM version).
I've come to the conclusion that it might have to do with the version of RVM? Have I missed something obvious? Any suggestions would be greatly appreciated.
you should rather update then downgrade, you real problem is that you specify ruby version without patchlevel, in this case RVM will take the latest known patchlevel, so instead of rvm use 1.8.7 you need to tell it rvm use 1.8.7-p334.
As for the downgrade question you can specify version rvm get 1.2.8, just keep in mind this version is about 2 years old, a lot of things was fixed in rvm since then, and you will not get any support for the old version.
yes it is possible. You can do it.
Previously i was using rvm version 1.29.0
I tried with this code to use rvm with the version of 1.28.0
Code is : rvm get 1.28.0
I recently updated my Ruby version to 1.9.2 through RVM. (And, is it normal that I have to use the command rvm use 1.9.2 EVERY TIME when starting the terminal?).
I deleted some Rails files I shouldn't have, so I reinstalled Rails. However, I still get this error when trying to generate controllers:
Could not find mail-2.2.9.1 in any of the sources
Try running bundle install.
Running bundle install solves the problem for the moment, but I get the same error when starting another project.
you need to use an rvmrc file. it tells rvm which ruby version / gemset to use. read:
https://rvm.io/workflow/rvmrc/