Why i am getting the NoMethodError 'undefined method `source'' after running the gemfile

Im new on Ruby on Rails. I am using the newest version of  Ruby, Rails and RubyMine and i would like to run the gemfile with  RubyMine. But i am getting the following NoMethodEffor:

{location}:in

<top (required)>': undefined method
source' for main:Object (NoMethodError)     from -e:1:in
load'     from -e:1:in
'

The error occurred by running the line

source 'http://rubygems.org'

of the gemfile.

This are my installed gems with the current version number: abstract (1.0.0) actionmailer (3.0.10) actionpack (3.0.10) activemodel (3.0.10) activerecord (3.0.10) activeresource (3.0.10) activesupport (3.0.10) archive-tar-minitar (0.5.2) arel (2.2.1, 2.0.10) builder (3.0.0, 2.1.2) bundler (1.0.18) columnize (0.3.4) erubis (2.7.0, 2.6.6) haml (3.1.2) i18n (0.6.0, 0.5.0) linecache19 (0.5.12) mail (2.3.0, 2.2.19) mime-types (1.16) minitest (2.5.0, 1.6.0) polyglot (0.3.2) rack (1.3.2, 1.2.3) rack-mount (0.8.2, 0.6.14) rack-test (0.6.1, 0.5.7) rails (3.0.10) railties (3.0.10) rake (0.9.2, 0.8.7) rdoc (3.9.2, 2.5.8) ruby-debug-base19x (0.11.28) ruby-debug-ide (0.4.17.beta5) ruby_core_source (0.1.5) rubygems-update (1.8.8) thor (0.14.6) treetop (1.4.10) tzinfo (0.3.29)

Thanks for your respones.
4 comments
Comment actions Permalink

{location}:in

<top (required)>': undefined method
source' for main:Object (NoMethodError)     from -e:1:in
load'     from -e:1:in
'

Is it full error output? Or you attached only small part?

i would like to run the gemfile with  RubyMine. But i am getting the following NoMethodEffor:


Do you run "Gemfile" as Ruby script (from context menu, 'Run "Gemfile"' action) ? Gemfile cannot be launched, it is config for bundler, you need to launch Tools | Bundler | Install or other bundler cmd.
0
Comment actions Permalink

Yes. Thats the full error output.

Yesterday Serge Baranov told me what you said. But i don't now why the functionality to run the Gemfile in RubyMine is available? I have been understand that the gemfile are used to manage the dependencies on my project and load not available gems on my local machine from rubygems.org and put them to my project. Is it right? Thats the reason why i would like to run the gemfile manually. So that the unavailable gems will be load from rubygems.org.

If i use the functionality Tools | Bundler | Install then i can install unavailable gems. But only one gem. I would like to to install all unavailable gems to my project automaticlly. How can i do that?

0
Comment actions Permalink

But i don't now why the functionality to run the Gemfile in RubyMine is available?

Gemfile is a file written in Ruby language. By default RubyMine allows to launch all Ruby scripts. I've just fixed RubyMine not to suggest launch Gemfile from context menu.

I have been understand that the gemfile are used to manage the dependencies on my project and load not available gems on my local machine from rubygems.org and put them to my project. Is it right? Thats the reason why i would like to run the gemfile manually.

Yes, but you shouldn't launch Gemfile directly. Gemfile is like a config file written in Ruby DSL. Bundler gem loads it and uses to install/update/etc gems

If i use the functionality Tools | Bundler | Install then i can install unavailable gems. But only one gem.


No, "bundle install" installs all missing gems from Gemfile, "bundle update" updates them, etc (see official bundler documentation). RubyMine "Tools | Bunlder" submenu is for quickly launch bundler commands.

I would like to to install all unavailable gems to my project automaticlly. How can i do that?

Installing gems is CPU consuming operation, requires internet conection, so RubyMine doesn't install missing gems automatically in backgrounds. But you can install missed gems manually using "Tools | Bunlder | Install" actions (no additonal parameters are required by default). Also RubyMine check your Gemfile after you've edited it and suggests to "Install missing files" using bundler (red popup in top-right corner)

0
Comment actions Permalink

Thanks Roman. Now I understand ;).

0

Please sign in to leave a comment.