简体   繁体   中英

When Rails app is accessed from a new terminal, all gems are deleted

This bizarre...I replaced the hard drive on my computer and reinstalled Ubuntu 14.04, and cloned my Rails app. I set it all up, ran bundle install, and everything went fine.

But when I open a new terminal and access the app from it, the new terminal thinks that my app doesn't have any gems installed. Even rails -v returns

$ rails -v
The program 'rails' can be found in the following packages:
 * ruby-railties-3.2
 * ruby-railties-4.0
Try: sudo apt-get install <selected package>

and bundle install returns

Your Ruby version is 1.9.3, but your Gemfile specified 2.0.0

But on the terminal I used to set up my app (both terminals are open at the same time) if I run rails -v I get the normal output "Rails 4.0.10 ", and bundle install executes normally.

I'm pretty sure if I were to quit out of the terminal I used to set it up, all the changes I've made to my app would be reverted for good, but I don't want to test that theory.

How is it possible for two simultaneous terminals to see a project differently??

Output of rvm list for BOTH terminals

$ rvm list


rvm rubies

=* ruby-2.0.0-p643 [ x86_64 ]

# => - current
# =* - current && default
#  * - default

UPDATE

I closed all open terminals and opened up a new one, and reinstalled RVM and ruby. No matter how many times I do this, ruby -v always returns

ruby 1.9.3p484 (2013-11-22 revision 43786) [x86_64-linux]

but rvm install 2.0.0 returns

Already installed ruby-2.0.0-p643.
To reinstall use:

    rvm reinstall ruby-2.0.0-p643

Your rvm setup isn't right. A new terminal is running the rvm shims (paths to rvm ruby and gems), and the old terminal is pointing to a different ruby version, maybe even the system ruby; or vice versa.

Close all terminals, start a fresh one, check to see if RVM is set up correctly with the bash hooks; then bundle install.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM