mixbo
mixbo

Reputation: 35

rails why need other project bundle gems?

i have two project,which one called A with Rails another called B just pure Ruby code.

when i call A controller actions named do_action it will call B rake tasks such rake dosomething

but i got error:

rake aborted!
cannot load such file -- pry

the gem pry in B Gemfile.

i want to know why rails project A will need B Gemfiles gems?

i think my linux env probelem? thk

Upvotes: 0

Views: 60

Answers (1)

Малъ Скрылевъ
Малъ Скрылевъ

Reputation: 16507

Since you have call to rake dosomething to other's project from the specific (first) one, the environment gems will be applied from the first project. So, either:

  1. add the pry gem dependency into the first project

  2. generate the second project, which is in pure ruby, as a gem, and add it as a dependency into Gemfile of your Rails project as follows:

    gem 'your_ruby_project_gem', :path => 'path/to/your/ruby/gem/project'
    

    The way is for the projects, which are current under a development, i.e. the argument :path allows you to change the code under that path, so you gem will be also changed without reinstallation. Refer to more the bundler documentation. To run the Rails project you have to exec as follows:

    bundle exec rails s
    

I prefer the second approach.

Upvotes: 1

Related Questions