curationexperts / epigaea

A MIRA replacement running on Hyrax 2.0
Other
1 stars 2 forks source link

Don't load dev dependencies in production #147

Closed mark-dce closed 7 years ago

mark-dce commented 7 years ago

ISSUE When I got around to trying to deploy the application in a production like environment, I ran into dependency errors from rake tasks that only make sense in the development environment.

Tasks: TOP => deploy:assets:precompile
(See full trace by running task with --trace)
The deploy has failed with an error: Exception while executing as deploy@localhost: rake exit status: 1
rake stdout: Nothing written
rake stderr: rake aborted!
LoadError: cannot load such file -- solr_wrapper/rake_task
Tasks: TOP => deploy:assets:precompile
(See full trace by running task with --trace)
The deploy has failed with an error: Exception while executing as deploy@localhost: rake exit status: 1
rake stdout: Nothing written
rake stderr: rake aborted!
LoadError: cannot load such file -- rubocop/rake_task

In both cases rake tasks are loading code that depends on gems that are only loaded in the development environment.

My initial (ugly) solutions are: https://github.com/curationexperts/epigaea/blob/09f2c6c71cbbacc74b6b637b0a51b7d7178759f1/lib/tasks/rubocop.rake or https://github.com/curationexperts/epigaea/blob/09f2c6c71cbbacc74b6b637b0a51b7d7178759f1/lib/tasks/spec.rake

ACCEPTANCE

mark-dce commented 7 years ago

It turns out rubocop doesn't like the second option - to swallow the load error - so I ended up with the conditional block around both tasks.

no-reply commented 7 years ago

I think we agreed to do unless Rails.env.production?

mark-dce commented 7 years ago

Fixed in #185

scottkushner commented 6 years ago

So was this ever fixed? I'm getting this error now...

What are we supposed to do? Is there no workaround..>?

mark-dce commented 6 years ago

Scott - Yes, this was fixed by #185 and closed when that PR was merged. It's possible that additional dependencies have been added since then that cause a similar error.

Can you post the exact error you're getting - i.e. the portion that looks like LoadError: cannot load such file -- solr_wrapper/rake_task

That last bit, e.g. solr_wrapper/rake_task, should tell you exactly which rake task is being requested. Once you have the file name, take a look at #185 and see if the same strategy could work.

scottkushner commented 6 years ago

Ok, thanks...I did it like this...

I think it's because I ran........ bundle install --deployment --without development test (following the instruction from Passenger on Deploying a Ruby app with Debian 8...)

Then I got things to run by doing this...below

Also, for some reason after deployment, my original admin user on my development server couldn't see the Collection or Work Types in Hyrax... I think I will have to delete user and recreate.....(I think I've lost years on my life over this..!)

Thanks again,

ruby - LoadError: cannot load such file -- rspec/core/rake_task - Stack Overflow 1down vote In Production Environment

What happens is, capistrano is configured to only install gem bundle in production group(as in Gemfile). So it runs bundle command like bundle install --without development test. Want to verify?

Run bundle install command in project dir in Production environment, you will see following

Using devise 4.2.0Using activeadmin 1.0.0.pre4Using responsive_active_admin 0.0.5Bundle complete! 60 Gemfile dependencies, 133 gems now installed.Gems in the groups development and test were not installed.Bundled gems are installed into /path/to/your/app/production/shared/bundle.

Please note (Gems in the groups development and test were not installed.).

You might recall that you have specified rspec-rails gem to be installed in development mode only.

Solution

try to specify the RAILS_ENV like

For Rails 5.0 +

RAILS_ENV=production bundle exec rails -T

or

RAILS_ENV=production bundle exec rake -T

but this may not work

bundle exec rake -T RAILS_ENV=production

On Thu, Jul 26, 2018 at 4:16 PM, Mark Bussey notifications@github.com wrote:

Scott - Yes, this was fixed by #185 https://github.com/curationexperts/epigaea/pull/185 and closed when that PR was merged. It's possible that additional dependencies have been added since then that cause a similar error.

Can you post the exact error you're getting - i.e. the portion that looks like LoadError: cannot load such file -- solr_wrapper/rake_task

That last bit, e.g. solr_wrapper/rake_task, should tell you exactly which rake task is being requested. Once you have the file name, take a look at #185 https://github.com/curationexperts/epigaea/pull/185 and see if the same strategy could work.

— You are receiving this because you commented. Reply to this email directly, view it on GitHub https://github.com/curationexperts/epigaea/issues/147#issuecomment-408221757, or mute the thread https://github.com/notifications/unsubscribe-auth/AaHCswbxRAQt20g2gS2jPtrXcolfgnKwks5uKiOWgaJpZM4Ou9pk .

-- Scott Kushner Systems and Emerging Technologies Librarian

Saint Peter's University The Jesuit University of New Jersey

Theresa & Edward O'Toole Library 99 Glenwood Ave. Jersey City, New Jersey 07306

p: (201) 761-6456 f: (201) 761-6451

www.saintpeters.edu/library

mark-dce commented 6 years ago

It sounds like you're dealing with a more general Hyrax application than the MIRA application (or epigaea - which is the Tufts University project this repo is for). You might want to e-mail the samvera-tech@googlegroups.com or chat with folks on the Samvera community slack channel. You can get info about how to get in touch here https://wiki.duraspace.org/pages/viewpage.action?pageId=87460391

scottkushner commented 6 years ago

Thanks.

On Thu, Jul 26, 2018 at 5:41 PM, Mark Bussey notifications@github.com wrote:

It sounds like you're dealing with a more general Hyrax application than the MIRA application (or epigaea - which is the Tufts University project this repo is for). You might want to e-mail the samvera-tech@googlegroups.com or chat with folks on the Samvera community slack channel. You can get info about how to get in touch here https://wiki.duraspace.org/pages/viewpage.action?pageId=87460391

— You are receiving this because you commented. Reply to this email directly, view it on GitHub https://github.com/curationexperts/epigaea/issues/147#issuecomment-408243855, or mute the thread https://github.com/notifications/unsubscribe-auth/AaHCs-cSHPojnPv7bsSq6GNqtBWKltCPks5uKjdxgaJpZM4Ou9pk .

-- Scott Kushner Systems and Emerging Technologies Librarian

Saint Peter's University The Jesuit University of New Jersey

Theresa & Edward O'Toole Library 99 Glenwood Ave. Jersey City, New Jersey 07306

p: (201) 761-6456 f: (201) 761-6451

www.saintpeters.edu/library