Rails : Could not locate Gemfile - ruby-on-rails

/Users/mac/.rvm/gems/ruby-2.1.3#global/gems/bundler-1.7.4/lib/bundler/shared_helpers.rb:24:in `default_gemfile': Could not locate Gemfile (Bundler::GemfileNotFound)
from /Users/mac/.rvm/gems/ruby-2.1.3#global/gems/bundler-1.7.4/lib/bundler/shared_helpers.rb:29:in `default_lockfile'
from /Users/mac/.rvm/gems/ruby-2.1.3#global/gems/bundler-1.7.4/lib/bundler.rb:253:in `default_lockfile'
from /Users/mac/bin/spring:10:in `<top (required)>'
from bin/rails:3:in `load'
from bin/rails:3:in `<main>'
hi,
when i try to run 'rails new myproject' or 'rails -v' i have this message but rails is installed. i don't understand. Someone can help me.
Thanks for your help.

I had the exact problem.
As it turned out, the problem was I had a hidden ./bin directory.
When I run rails new myapp, it's using binaries in the bin folder. In my case it was ./bin/spring specifically.
I removed this ./bin directory and all is well now.

It's either not in the proper path or it isn't installed. Do this gem install bundler also if you are running rails -v you should get a version like this:
rails -v
Rails 4.2.0.beta2
If you don't, then that means rails is not installed either. Run gem install rails
Here is information of setting up rails: http://guides.rubyonrails.org/getting_started.html

Related

Cannot launch cloned ruby on rails app - RubyMine

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?

no such file to load -- initializer (LoadError)

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 .

Error with new Rails 3.2.8 project - `require': cannot load such file -- sqlite3/sqlite3_native (LoadError)

I've just created a new amazon Linux instance and installed ruby 1.9.3 and rails 3.2.8.
Upon creating a new project I immediately receive failures due to sqlite3. The error is:
[root#xxxxx fun]# rails server
/usr/local/share/gems/gems/sqlite3-1.3.6/lib/sqlite3.rb:6:in `require': cannot load such file -- sqlite3/sqlite3_native (LoadError)
from /usr/local/share/gems/gems/sqlite3-1.3.6/lib/sqlite3.rb:6:in `rescue in <top (required)>'
from /usr/local/share/gems/gems/sqlite3-1.3.6/lib/sqlite3.rb:2:in `<top (required)>'
I have confirmed that sqlite3 is working just fine outside of rails (i.e. I successfully created a database, did inserts/reads using ruby code). Here is a quick show of loading sqlite3 in irb:
irb(main):001:0> require 'sqlite3'
=> true
I'm all up to date with bundle install. sqlite3 is at version 1.3.6
I have the following packages installed:
ruby19-1.9.3.0-7.17.amzn1.i686
ruby19-devel-1.9.3.0-7.17.amzn1.i686
ruby19-irb-1.9.3.0-7.17.amzn1.noarch
ruby19-libs-1.9.3.0-7.17.amzn1.i686
rubygem19-io-console-0.3-7.17.amzn1.i686
rubygem19-rdoc-3.9.4-7.17.amzn1.i686
rubygems19-1.8.11-7.17.amzn1.noarch
sqlite-3.6.20-1.8.amzn1.i686
sqlite-devel-3.6.20-1.8.amzn1.i686
Any ideas on what I could try to get things working? Thanks!
Update
For "fun" I commented out the gem sqlite3 line from my Gemfile and tried "rails server" again. First it complained about not having a javascript runtime (which I could fix) but then it is getting the following. There seems to be something royally wrong with my install.
[root#xxxx fun]# rails server
/usr/local/share/gems/gems/railties-3.2.8/lib/rails/railtie/configuration.rb:85:in `method_missing': undefined method `active_record' for #<Rails::Application::Configuration:0x9e68f58> (NoMethodError)
from /srv/rails/fun/config/application.rb:54:in `<class:Application>'
from /srv/rails/fun/config/application.rb:13:in `<module:Fun>'
from /srv/rails/fun/config/application.rb:12:in `<top (required)>'
You may have a path problem.
To see if you have more than one version of Ruby, Rails, or gem installed:
find / | grep bin/ruby
    find / | grep bin/rails
    find / | grep bin/gem
On Amazon servers, I typically keep the system Ruby as is, and install my own current Ruby by using the excellent ruby-build script (better than RVM, in my opinon).
https://github.com/sstephenson/ruby-build
If you do have more than one Ruby, I suggest that you set your environment to choose one, for example by using ruby-build or by setting your PATH in your .bashrc file or /etc/environment file something like this:
PATH=/opt/ruby/1.9.1-p134/bin;$PATH
If you're using RVM, I suggest you uninstall it and change to use ruby-build.
To uninstall RVM, I use this script:
https://github.com/SixArm/sixarm_unix_shell_scripts/blob/master/rvm-uninstall-danger

Trying to install rails- EISDIR error

I'm new to programming and am trying to set up Ruby on Rails using Michael Hartl's tutorial via Terminal on a Mac running Snow Leopard, but I'm a bit stuck on this part. I've tried using rvm 1.9.2, without any luck, and haven't been able to find anything googling. Any help would be appreciated!
Thanks!
CZom$ gem install rails -v 3.2.3
/Users/CZom/.rvm/rubies/ruby-1.9.3-p194/lib/ruby/site_ruby/1.9.1/rubygems/config_file.rb:253:in `read': Is a directory - /Users/CZom/.gemrc (Errno::EISDIR)
from /Users/CZom/.rvm/rubies/ruby-1.9.3-p194/lib/ruby/site_ruby/1.9.1/rubygems/config_file.rb:253:in `load_file'
from /Users/CZom/.rvm/rubies/ruby-1.9.3-p194/lib/ruby/site_ruby/1.9.1/rubygems/config_file.rb:191:in `initialize'
from /Users/CZom/.rvm/rubies/ruby-1.9.3-p194/lib/ruby/site_ruby/1.9.1/rubygems/gem_runner.rb:78:in `new'
from /Users/CZom/.rvm/rubies/ruby-1.9.3-p194/lib/ruby/site_ruby/1.9.1/rubygems/gem_runner.rb:78:in `do_configuration'
from /Users/CZom/.rvm/rubies/ruby-1.9.3-p194/lib/ruby/site_ruby/1.9.1/rubygems/gem_runner.rb:51:in `run'
from /Users/CZom/.rvm/rubies/ruby-1.9.3-p194/bin/gem:25:in `<main>'
/Users/CZom/.gemrc should be a user specific config file that gets loaded when executing the gem command. Sounds like in your case it is a directory instead. Rubygems is complaining therefore.
Try to rename /Users/CZom/.gemrc or remove it completely if it isn't needed.

Ruby, Rails console start with error...need help

> luke#Macbook-Pro~/Documents/workspace/RoR/rails_projects/sample4_app$ ruby -v
ruby 1.8.7 (2011-06-30 patchlevel 352) [i686-darwin10.8.0]
luke#Macbook-Pro~/Documents/workspace/RoR/rails_projects/sample4_app$ rails -v
Rails 3.0.9
luke#Macbook-Pro~/Documents/workspace/RoR/rails_projects/sample4_app$ rails console
/Users/luke/.rvm/rubies/ruby-1.8.7-p352/lib/ruby/1.8/i686-darwin10.8.0/readline.bundle: dlopen(/Users/luke/.rvm/rubies/ruby-1.8.7-p352/lib/ruby/1.8/i686-darwin10.8.0/readline.bundle, 9): Symbol not found: _rl_basic_quote_characters (LoadError)
Referenced from: /Users/luke/.rvm/rubies/ruby-1.8.7-p352/lib/ruby/1.8/i686-darwin10.8.0/readline.bundle
Expected in: flat namespace
in /Users/luke/.rvm/rubies/ruby-1.8.7-p352/lib/ruby/1.8/i686-darwin10.8.0/readline.bundle - /Users/luke/.rvm/rubies/ruby-1.8.7-p352/lib/ruby/1.8/i686-darwin10.8.0/readline.bundle
from /Users/luke/.rvm/rubies/ruby-1.8.7-p352/lib/ruby/1.8/irb/completion.rb:10
from /Users/luke/.rvm/gems/ruby-1.8.7-p352/gems/railties-3.0.9/lib/rails/commands/console.rb:3:in `require'
from /Users/luke/.rvm/gems/ruby-1.8.7-p352/gems/railties-3.0.9/lib/rails/commands/console.rb:3
from /Users/luke/.rvm/gems/ruby-1.8.7-p352/gems/railties-3.0.9/lib/rails/commands.rb:20:in `require'
from /Users/luke/.rvm/gems/ruby-1.8.7-p352/gems/railties-3.0.9/lib/rails/commands.rb:20
from script/rails:6:in `require'
from script/rails:6
Ruby is okay, Rails is okay, but "rails console"
Need help
Thanks
Looks like you're missing a file in your ruby build. Did you just recently update to OS X 10.7? You might need a fresh reinstall of Rails. As always this can be done with:
sudo gem install rails
Sorry I can't be of more help.
Suggest using bundler to manage the gems in your project.
If you put
source 'http://rubygems.org'
gem 'rails', '3.0.9'
in your Gemfile (see also http://gembundler.com/ )
Then
bundle install
will install the correct version of rails and
bundle exec rails console
will start up your console. bundle exec rails server will start the server, etc.
You might also want to consider using rvm to install and manage your rubies if you aren't already -- http://beginrescueend.com/

Resources