So I'm a rails developer familiar with Rails 3 and 4. I'm taking on a Rails 1.1.2 project, and the first problem I'm having is getting the server running.
I'd really love some help figuring out what I'm missing setting up the environment. When I run script/server, I get:
-bash: script/server: /Users/michael/.rvm/gems/ruby-1.9.3-p545: bad interpreter: Permission denied
This is after noting that at the top of the script/server file, there's an opportunity to define the location of the ruby install with a ruby comment:
#!/Users/michael/.rvm/gems/ruby-1.9.3-p545
At least, this is how I understand it. What should this comment point to? Does this look correct? I've installed ruby 1.9.3 using rvm and installed rails V 1.1.2 through sudo gem install rails. Everything seemed to work fine.
Is this some kind of bash permissions issue? I really don't understand what's going on. Any help would be appreciated!
I believe a rails project that old will require Ruby 1.8.7, so you should start with an older version of Ruby just to be sure. Once you get it running with the older ruby version, you can try 1.9 again, but trying it with 1.8.7 should help you out a bit. Your shebang should be able to do this though:
#!/usr/bin/env ruby
It needs the path of the ruby interpreter, which can be obtained dynamically via the above line.
Related
Forgive me if there's a duplicate, but I'm honestly not sure what to search for. I'm working on a project with Ruby on Rails, and I get this message when doing anything related (ie: rake, rails, rspec, etc.):
Your Ruby version is 2.1.5, but your Gemfile specified 2.2.3
Now, I've installed RVM and I can fix this issue by issuing the command
bash --login
edit for clarity
running the above command does use Ruby 2.2.3 to execute the commands.
/edit
Then those given commands work. What I would like to do is to remove version 2.1.5 entirely -- leaving only 2.2.3. I've gone about this so many different ways, but Ruby is pretty foreign territory to me so I'm not sure what to do about this. I'm sure I have at least three installations of Ruby on my machine - possibly two duplicates of the two versions I know I have - and I would like only one version and to avoid needing to enter the bash --login command in order to run my project.
I'm running Ubuntu 15.10 and have at least some knowledge of how this works. If somebody could walk me through removing everything related to Ruby & Ruby on Rails, then installing only Ruby 2.2.3 and Rails 4.2.4, I would greatly appreciate that. Let me know if this isn't the proper exchange for this question. It didn't quite seem to fit into Ubuntu or Sysadmin.
What you need to do is not try to remove ruby 2.1.5.
You have RVM, so, use that to get the new version you want.
After this, you now have two options:
1) make the newly installed version the global default version on your machine,
or
2) create a gemset for your project, and specify the needed ruby version for the project.
Either of these will fix your problem.
You have to modify the Gemfile.
http://bundler.io/v1.3/gemfile_ruby.html
TLDR: How do I force a rails app to use the correct ruby interpreter?
Hello,
Something hosed parts of my Ruby 1.9.2p290 install (certain classes just went missing one day), so I removed it and attempted to reinstall the environment.
I'm running on Snow Leopard.
Ruby 1.9.2 was installed from source. (I tried to install via MacPorts and it would fail). I am not keen on RVM as I use bundler and I seem to recall some problems with how bundler and RVM interact, though from what I can tell RVM works.
After reinstalling a few gems I noticed they were being placed in a gem folder for Ruby 1.8. "This is weird," I thought.
Starting up the rails app, I notice a lot of weird exceptions being thrown regarding syntax. After printing RUBY_VERSION to stdout, I noticed that the Rails app is running 1.8.7.
which ruby shows only one ruby interpreter:
$ which ruby
/usr/bin/ruby
$ /usr/bin/ruby -v
ruby 1.9.2p290 (2011-07-09 revision 32553) [x86_64-darwin10.8.0]
If I open up Activity Monitor, the ruby process from the Rails app lives at /System/Library/Frameworks/Ruby.framework/Versions/1.8/usr/bin/ruby, which I believe is the ruby interpreter that OSX shipped with.
I haven't found any information on completely purging Ruby from OSX. I would love to do that then simply install ruby from source.
It seems there are two problems:
Rails is running a ruby interpreter that I have no idea how it is calling, when I need it to run the 1.9.2 interpreter installed from source
gems are being installed in a 1.8 folder, I suspect because gem thinks its running under 1.8
How do I fix this?
Thank you,
Tom
I guess the best way to overcome this issue is using rvm to handle your Ruby and Rails environments through 'gemset's.
I had the same issue and I use gemsets now without a problem.
This is the article which I got things working:
http://stjhimy.com/posts/10-five-quick-steps-to-set-up-rvm-with-rails-2-and-rails3
I setup rails 3.1.0.rc5 on my friends vista machine last week. Everything installed and i can run an application we're working on just fine, however, the rails command does not resolve. To start the server, i had to do the old fashioned: ruby script/rails s style. He has the ruby bin on his path, as ruby -v resolves fine. Any ideas on what to check?
Note i downloaded a 1.9.2 installer from rubyinstaller.org, setup the dev pack, and installed rails through bundler.
It sounds like your path isn't pointing to your rails gem bin.
My first suggestion was going to be use rvm but since you're on windows that won't be an option. RVM suggested pik for windows users, and if it works similar to RVM, you'll save yourself a ton of headaches.
i am just starting with RoR and working through some tutorials, there is however a particular piece of code on github that i would like to look at, i have cloned it to my local and cd into the project but 'rails s' does not seem to start the server - any ideas what i need to do?
That's a Rails 2.3.2 app. rails s was introduced in Rails 3, so you'll have to use the older script/server start command.
Also, you're going to need rails 2.3.2, which you can install with gem install -v=2.3.2 rails. There's also the possibility that you're missing some required gems, which you'll find out about by running the app and watching for load errors.
Also, make sure you're running Ruby 1.8.7, not Ruby 1.9.2. Rails 2.3.2 does not work with Ruby 1.9.2
I used railstutorial.org to install the latest version of ruby and the latest version of rails on my machine.
at the end of the installation I checked
ruby -v ==> 1.9.2 (great)
rails -v ==> 3.0.1 (great)
this morning I opened up terminal
ruby -v
ruby 1.8.6 (2009-06-08 patchlevel 369) [universal-darwin9.0]
rails -v
Rails 1.2.6
what happened?
My advice for people who are installing ruby is to use RVM. It makes managing your ruby versions and gem versions really simple and you can install multiple ruby versions side by side.
You might want to read this post:
http://rubylearning.com/blog/2010/12/20/how-do-i-keep-multiple-ruby-projects-separate/
You can use Cinderalla to the whole ruby/rvm/mysql/redis/git/... stack set up properly. Cinderella installs everything in ~/Developer and fixes up your PATH as well. I had some issues with a corrupt git mirror last time I used Cinderalla though so YMMV.
With many unix variants, you are likely to have multiple versions of Ruby--particularly if you installed Ruby 1.9 and the system already had 1.8 installed. Essentially, the 1.8 version of Ruby has a higher precedence in your PATH than the 1.9 version. The Ruby Gems command keeps the libraries separate between 1.8 and 1.9 so that the platform will be reasonably stable.
To correct the problem, you have to find where ruby 1.9 is installed. Once you do that, you'll need to override your PATH variable. Assuming 1.9 is installed in the path: /opt/ruby-1.9.2, you will need to set your PATH like this:
PATH=/opt/ruby-1.9.2/bin:$PATH
export PATH
To make the path respect what you want every time, add that to your ~/.profile file (create it if necessary). Once the path has been set, it sould be able to find the correct version of Rails again.
I cannot say for certain because I cannot debug you OSX machine from here, however, I had a very similar occurrence. The problem was caused because I had installed ruby and then rails on my machine using sudo or from the root account. Then when I discovered rvm I installed everything in my user account. When I logged off and back in I appeared to lose everything. I was pulling out my hair. I was pissed that I was going to have to reinstall everything again... when I found the magic.
from the command line execute the command:
rvm list
you'll see that your new version of ruby is there. you'll also notice the tokens that indicate that it is just a normal version. It is not current or default. (see it yet)
Now if you run the command:
rvm use 1.9.2 --default
then every time you login/off and restart your machine your user account will default to that version of ruby and all of the gems that you installed against that version.