I am trying to run a Rails 2.3 app locally.
script/server gives me these errors:
bash: script/server: Permission denied
bash: parse_git_branch: command not found
script/server gives me the error:
/Users/stevenbrooks1111/.rvm/rubies/ruby-1.9.3-p429/lib/ruby/site_ruby/1.9.1/rubygems/custom_require.rb:55:in `require': cannot load such file -- initializer (LoadError)
from /Users/stevenbrooks1111/.rvm/rubies/ruby-1.9.3-p429/lib/ruby/site_ruby/1.9.1/rubygems/custom_require.rb:55:in `require'
from /Users/stevenbrooks1111/Desktop/cssmixonline/cssweb/config/boot.rb:55:in `load_initializer'
from /Users/stevenbrooks1111/Desktop/cssmixonline/cssweb/config/boot.rb:38:in `run'
from /Users/stevenbrooks1111/Desktop/cssmixonline/cssweb/config/boot.rb:11:in `boot!'
from /Users/stevenbrooks1111/Desktop/cssmixonline/cssweb/config/boot.rb:110:in `<top (required)>'
from /Users/stevenbrooks1111/.rvm/rubies/ruby-1.9.3-p429/lib/ruby/site_ruby/1.9.1/rubygems/custom_require.rb:36:in `require'
from /Users/stevenbrooks1111/.rvm/rubies/ruby-1.9.3-p429/lib/ruby/site_ruby/1.9.1/rubygems/custom_require.rb:36:in `require'
from script/server:2:in `<main>'
bash: parse_git_branch: command not found
Any ideas of how I can get this to run locally?
This question is what I've been doing for the past month. I would have loved to use Rails 4, but I know better than to try it!
Install rvm or rbenv, then get into a server that correctly runs this app, and run
ruby --version
gem list > ~/myGems.txt
Using rvm or rbenv, install the exact same version of Ruby.
(Tip: whenever I say "exact same", you can fudge by bumping the revision. For example, given a gem with version 0.1.4, if it has subsequent versions 0.1.5, 0.1.6, and 0.2.0, you can bump to 0.1.6, if that will save you some grief. The revision numbers, 0.1.*, are supposed to be only bug fixes. But a minor version bump, 0.2.0, has higher odds of breaking things. I kept the same version of Ruby, but I bumped rails to 2.3.14.)
Using rvm or rbenv, install the same version of Ruby as currently runs on this app's main server.
Inside this Ruby environment (with both which ruby and ruby --version reporting the correct answers), install each gem in myGems.txt, like this:
gem install --ignore-dependencies --no-rdoc --no-ri my_gem -v=0.1.4
The --ignore-dependencies is critical, because some gems from the Pleistocene Epoch, 2009, don't specify their dependencies' versions. When some dumb 2009 gem pulls in the 2013 rake, you will be utterly screwed, because reverting that rake is really hard. And don't forget to set the -v to the same value as myGems.txt reports!
After all that, try simple rake commands like rake routes. Post any bugs you get as fresh questions, but remember to point out Rails 2.3 in the subject so nobody mis-answers with the modern fixes.
And if this app has tests or specs, getting them running should be a top priority, so you can resume TDD, leaning on the tests to allow you to make sick changes.
Related
I have cloned an existing project from github. I installed Ruby and installed Rails on my Terminal.
When I do ruby -v I get ruby 2.5.3p105 (2018-10-18 revision 65156) [x86_64-darwin18]
When I do rails -v I get Rails 6.0.3.1
However when I navigate into my project that I want to run on local host and run the same commands:
for ruby -v I get ruby 2.5.3p105 (2018-10-18 revision 65156) [x86_64-darwin18] which is the same.
and for rails -v I get:
Traceback (most recent call last):
4: from bin/rails:3:in `<main>'
3: from bin/rails:3:in `load'
2: from /Users/angelainniss/WebstormProjects/legitkitchen/bin/spring:8:in `<top (required)>'
1: from /Users/angelainniss/.rbenv/versions/2.5.3/lib/ruby/2.5.0/rubygems/core_ext/kernel_require.rb:59:in `require'
/Users/angelainniss/.rbenv/versions/2.5.3/lib/ruby/2.5.0/rubygems/core_ext/kernel_require.rb:59:in `require': cannot load such file -- bundler (LoadError)
Has anyone ever had this or do they understand why rails isn't working?
Well, rails command is pretty smart and it knows it will be usually called within the rails project folder. So it have its binstubs - basically those are just a slightly modified commands that lives in your project bin folder, with some additional, project-related power-ups. Regular rails command (and other commands as well) will always check if bin/rails is present in current directory and will use it if it exists. This is why rails -v worked fine outside of your project but didn't inside project folder.
One of the bin/rails superpowers is automatic requiring of all dependencies defined in your project Gemfile. This is normally done through another gem called bundler. Bundler is basically always the first gem you're gona install in your local Ruby environment.
But, you didn't install it yet. Just run gem install bundler to get that running. You will still need to install all the dependencies, you do this via bundle install.
Did you do, gem install bundler before running bundle install after cloning the project?
Versions, dependencies, and other information:
Ruby: 1.9.3p392 (2013-02-22) [i386-mingw32]
Rails: 3.2.13
Gemfile located at: http://pastebin.com/z9u40Jca
For some reason, whenever I run any gem based command, it gives me this error:
$ rails s
c:/RailsInstaller/Ruby1.9.3/lib/ruby/1.9.1/rubygems.rb:30:in `require': cannot l
oad such file -- rubygems/defaults (LoadError)
from c:/RailsInstaller/Ruby1.9.3/lib/ruby/1.9.1/rubygems.rb:30:in `<top
(required)>'
from <internal:gem_prelude>:1:in `require'
from <internal:gem_prelude>:1:in `<compiled>'
I have tried deleting ruby 2.0.0 from pik and the rails installer folder, because another SO thread said that would fix it. The commands were working as of 5 hours ago, and must have stopped right when I finished using the rails console (part of learning rails from this tutorial, it was just basic math and string manipulation, so I don't think I screwed something up). Any ideas on what I should do?
Try deleting 'ruby '1.9.3' ' from your gem file. It shouldn't be causing a problem, but I've seen situations where it has.
I don't know if I did something I don't know about, but to the best of my knowledge, adding the gem "bootstrap-sass" at version 2.3.2.0 got it working again. I doubt that it was adding that exact gem that was the solution, but you never know.
I have following installed on ubuntu 12
ruby 1.9.2p320
Rails 3.2.6
Now I have old project which is developed into Rails 2 & Ruby 1.8.7
Problem:
When i run below command under old project root directory
ruby ./script/plugin install git://github.com/rails/rails_upgrade.git
Following error comes
Invalid gemspec in [/usr/local/rvm/gems/ruby-1.9.2-p320/specifications/ZenTest-4.9.1.gemspec]: Illformed requirement ["< 2.1, >= 1.8"]
/usr/local/rvm/rubies/ruby-1.9.2-p320/lib/ruby/site_ruby/1.9.1/rubygems/custom_require.rb:55:in `require': no such file to load -- initializer (LoadError)
from /usr/local/rvm/rubies/ruby-1.9.2-p320/lib/ruby/site_ruby/1.9.1/rubygems/custom_require.rb:55:in `require'
from /var/www/project/client/softwallet/config/boot.rb:54:in `load_initializer'
from /var/www/project/client/softwallet/config/boot.rb:38:in `run'
from /var/www/project/client/softwallet/config/boot.rb:11:in `boot!'
from /var/www/project/client/softwallet/config/boot.rb:109:in `<top (required)>'
from <internal:lib/rubygems/custom_require>:29:in `require'
from <internal:lib/rubygems/custom_require>:29:in `require'
from ./script/plugin:2:in `<main>'
Upgrading the old rails project to new one and getting the invalid gemspec problem.
Then you have to do the following:
Run gem update --system followed by bundle install.
UPDATE:
You are using the same old config/boot.rb from your older version of rails application.
Do the following:
1) Create a new project directory.
2) Generate a new rails app (Of your new latest rails version)
3) Use boot.rb that is created by it.
This happens when you have incompatible version of the same gem already installed on your environment.
To rectify, either you can uninstall and reinstall the gem or install the gem of the specific version.
Make sure that you do a gem cleanup operation before doing so.
This is how my problem was solved . I was using RVM and if you have edited those .bashrc files then each time while you log in to the shell , do a /bin/bash --login . What this does is , it makes the command line take note of the rvm path you had set and installs them first .
I did this on Ubuntu 12 and it did solve my issue , i don't think doing gem update --system is a good idea as it really kind of messes up the environment forcing one to do an rvm implode and install it all over again .
Can someone help me out with something seemingly simple? My newness to Ruby on Rails is the reason, no doubt. I cannot start up the server. It looks like the boot file cannot be located but I'm nor sure at all.
There are several versions of ruby here, related to installing rvm:
which -a ruby
/Users/me/.rvm/rubies/ruby-1.9.3-p327/bin/ruby
/Users/me/.rvm/bin/ruby
/usr/local/bin/ruby
/usr/bin/ruby
Probably need to remove some?
Using Rails 3.2.9 with Ruby 1.9.3 on a Mac Mini
Thanks!
cd [rails project dir]
$ script/server
/Users/me/.rvm/rubies/ruby-1.9.3-p327/lib/ruby/site_ruby/1.9.1/rubygems/custom_require.rb:36:in `require':
cannot load such file -- script/../config/boot (LoadError)
from /Users/me/.rvm/rubies/ruby-1.9.3-p327/lib/ruby/site_ruby/1.9.1/rubygems/custom_require.rb:36:in `require'
from script/server:2:in `'
This isn't the issue you are getting. script/server still works, what you are experiencing is an issue with the gems you are trying to use. What you might try is running rails s --trace, see what gems are causing the issue and manually reinstalling them. From the looks of it, it's just an issue with a lone gem with dependencies in 1.9.1.
With Rails 3+ you get access to the rails command line scripts so instead of calling script/server you just run rails server or rails s for short.
After upgrading my Rails install to Rails 3 on OS X, I’ve had problems running my Rails 2.x development sites with Mongrel. WEBrick seems to work, but I really would like to have the nice output of Mongrel for debugging.
After running $ script/server I get this:
/Library/Ruby/Gems/1.8/gems/activesupport-2.0.2/lib/active_support/dependencies.rb:489:in `load': no such file to load -- mongrel_rails (MissingSourceFile)
from /Library/Ruby/Gems/1.8/gems/activesupport-2.0.2/lib/active_support/dependencies.rb:489:in `load'
from /Library/Ruby/Gems/1.8/gems/activesupport-2.0.2/lib/active_support/dependencies.rb:342:in `new_constants_in'
from /Library/Ruby/Gems/1.8/gems/activesupport-2.0.2/lib/active_support/dependencies.rb:489:in `load'
from /Library/Ruby/Gems/1.8/gems/rails-2.0.2/lib/commands/servers/mongrel.rb:64
from /Library/Ruby/Site/1.8/rubygems/custom_require.rb:49:in `gem_original_require'
from /Library/Ruby/Site/1.8/rubygems/custom_require.rb:49:in `require'
from /Library/Ruby/Gems/1.8/gems/activesupport-2.0.2/lib/active_support/dependencies.rb:496:in `require'
from /Library/Ruby/Gems/1.8/gems/activesupport-2.0.2/lib/active_support/dependencies.rb:342:in `new_constants_in'
from /Library/Ruby/Gems/1.8/gems/activesupport-2.0.2/lib/active_support/dependencies.rb:496:in `require'
from /Library/Ruby/Gems/1.8/gems/rails-2.0.2/lib/commands/server.rb:39
from /Library/Ruby/Site/1.8/rubygems/custom_require.rb:49:in `gem_original_require'
So far, here’s what I’ve tried:
$ sudo gem update system
$ sudo gem update
$ sudo gem uninstall mongrel
$ sudo gem install mongrel --include-dependencies
$ which mongrel_rails
→ /usr/bin/mongrel_rails
$ mongrel_rails start
→ Success, but no stdout
$ which mongrel_rails
→ /usr/bin/mongrel_rails
$ rails _2.0.2_ test
→ Fresh application has same problem.
OS: OS X.6.x
Rails: 3.0.5 (problems are with Rails 2.x apps)
gem -v: 1.6.1
Mongrel: mongrel (1.1.5)
I’ve read EVERY Google result on "-- mongrel_rails (MissingSourceFile)"; there aren’t many.
Can anyone here tell me how to proceed in debugging this? Thanks!
UPDATE:
I’ve now tried installing older versions of the gem and specifying those in my Rails 2.x site’s config/environment.rb file. I’ve tried 1.1.5, 1.1.4, and 1.2.0pre.
None of these makes the slightest bit of difference.
Since the executable in in usr/bin I’m wondering if it’s a file ownership issue that got screwed up on my Rails 3 install and if one of the files isn’t getting my paths when it runs?
/Library/Ruby/Gems/1.8/gems/activesupport-2.0.2/lib/active_support/dependencies.rb
is owned by admin / root, so that should be OK, right?
Could it be a problem with active_support!?
Here’s the code from dependencies.rb that’s throwing the error:
484 class Object
485
486 alias_method :load_without_new_constant_marking, :load
487
488 def load(file, *extras) #:nodoc:
489 Dependencies.new_constants_in(Object) { super(file, *extras) }
490 rescue Exception => exception # errors from loading file
491 exception.blame_file! file
492 raise
493 end
...
This is getting a file not found error, so it’s not looking where I know the file to be…
Running mongrel_rails on command line works…
Which mongrel_rails shows it in usr/bin,
So what’s the problem?
I have got the same problem and found the reason.
This happens because new version of RubyGems(1.6.2) does not add 'any_gem/bin' to ruby load path ($LOAD_PATH) when you require "any_gem".
For example in RubyGems version = 1.4.1 this works fine. After I require 'mongrel' I can see in load path next:
...rvm/gems/ruby-1.8.7-p330/gems/mongrel-1.1.5/bin
...rvm/gems/ruby-1.8.7-p330/gems/mongrel-1.1.5/lib
...rvm/gems/ruby-1.8.7-p330/gems/mongrel-1.1.5/ext
With new version (1.6.2) I can see only:
...rvm/gems/ruby-1.8.7-p330/gems/mongrel-1.1.5/lib
...rvm/gems/ruby-1.8.7-p330/gems/mongrel-1.1.5/ext
That's why ruby cannot find 'mongrel_rails'.
You need to add "/usr/bin" to your load path. Perhaps something broke in it?
The best way to fix it is to add:
$:.push("/usr/bin/")
Somewhere before it breaks. Probably by itself in a config/preinitializer.rb file if you don't have one.
OK, here's ONE answer. I got mongrel to boot...but it's hacky, and doesn't solve the real problem...but at least for NOW I can get back to work on this project.
Here's what I did...YES..it's HACKY.
I edited the file throwing the error...dependencies.rb
I added a hook to call out the specific path to mongrel rails if that was the file it was trying to load.
def load(file, *extras) #:nodoc:
if file == "mongrel_rails"
file ="/usr/bin/mongrel_rails"
end
Dependencies.new_constants_in(Object) { super(file, *extras) }
rescue Exception => exception # errors from loading file
exception.blame_file! file
raise
end
Again, I would really like to fix the underlying problem here...but this at least let me boot up.
I would definitely look in to using RVM for running multiple gem versions simultaneously locally. I ran into a lot of quirks when I was attempting to run multiple versions like you are with sudo gem installs of everything.
Now it's as simple as rvm ree#my_app_1, and installing completely separate gems there, then switching to a different app and using rvm ree#my_app_2
ree is an alias for my install of ruby enterprise version, you could just as easily do it with ruby 1.9, 1.8.x, etc.
In each of my application's root directories I have a .rvmrc file that reads simply:
rvm ree#my_app --create
So that every time I switch to that directory, the gemset is automatically swapped for me.
I wasn't aware there was Rails 3 mongrel support.
Most people use Thin (you can enable it by specifying gem 'thin' in your Gemfile then launching rails server thin / Webrick these days.
If this is for hosting then there's nginx and Passenger that'll help with that.
I ran into the same problem -- got my app going by running "mongrel_rails" from the project directory (instead of "script/server").
This is the thread where you are able to find the best answer to the mongrel_rails (MissingSourceFile) error. I just want to conclude here how I solved the problem, using stuff in this thread.
The simplest solution I could figure out how to do was to downgrade RubyGems by typing
(sudo) gem update --system 1.4.1
This lets me run the old 2.1.0 app (thanks Max Shytikov), but there's probably a lot of bugfixes that I'm missing by running the old version of rubygems. The error is probably a blunder by the mongrel gem developers (I guess).
Anyway if you just want to run your app using mongrel do it like this. If you insist on having the newest version of rubygems, you can just run your app with
script/server webrick
But I've found that webrick is a fair bit slower, so I prefer mongrel. If anyone has got a better solution for this problem, please let me know.
I ran into the same error. The fix is to add the mongrel "bin" directory to the $LOAD_PATH. Other posts describe how to do it by modifying source code, but since I share source code with other developers, I prefer to set the RUBYLIB environment variable instead.
$ export RUBYLIB=/Users/edwingo/.rvm/gems/ruby-1.8.7-p302#junction/gems/mongrel-1.1.5/bin
This causes the MRI ruby runtime to prepend that to the $LOAD_PATH.
Detailed explanation: MRI is unable to find 'mongrel_rails' because it is not on the $LOAD_PATH. I am using RVM and when I installed mongrel into a gemset, for some reason the $LOAD_PATH does not include the corresponding "bin" directory where 'mongrel_rails' lives. When not using RVM and after installing mongrel into the system gems, the "bin" directory does appear on the $LOAD_PATH so it all works.