knapsack
knapsack copied to clipboard
Knapsack doesn't work with spring binstubs
Our app has binstubs generated by rails/spring in the application root/bin folder. So for example, here is Rails.root/bin/rspec
#!/usr/bin/env ruby
begin
load File.expand_path('../spring', __FILE__)
rescue LoadError => e
raise unless e.message.include?('spring')
end
require 'bundler/setup'
load Gem.bin_path('rspec-core', 'rspec')
So, we execute all commands with the bin/ prefix.
bin/rspec spec
bin/rails c
When we run knapsack
bundle exec knapsack:rspec
We get loads of errors, including undefined_method errors
How can we get Knapsack to play nice with our binstubs?
I saw you forked the gem https://github.com/synth/knapsack/commit/884069ccbdfc925fa81836e3a750efd4e2e41fb0 Does it solve your problem?
Yes, it solves it temporarily. Perhaps the rspec command can be parameterized.
In knapsack_pro gem I load the rspec task in a bit different way: https://github.com/KnapsackPro/knapsack_pro-ruby/blob/master/lib/knapsack_pro/runners/rspec_runner.rb
You may want to try the knapsack_pro gem to see if it works better for you.
is it possible to try knapsack_pro (just to see if it fixes the issue) without getting a license for it? Why doesn't knapsack free use the same way of loading rake tasks? It'd be nice to make sure that the free version works with spring binstubs too, since it's a fairly common thing.
(I'm having a similar issue and am trying @synth's fork, but it'd be nice to not have to do that)
Ah, bleh, my issue was not resolved by using the fork. So maybe it's a different issue.
Briefly, I have this code
if ENV['UPLOAD_CODECOV']
require 'simplecov'
require 'codecov'
SimpleCov.start 'rails' do
formatter SimpleCov::Formatter::Codecov
end
Rails.application.eager_load!
end
But when I use Knapsack it fails because Rails is undefined.
Hi @ibrahima
is it possible to try knapsack_pro (just to see if it fixes the issue) without getting a license for it?
Sure you can try https://knapsackpro.com for free. The trial is 14 days and days are count only when you use Knapsack Pro API. If you need more time to test it please just drop me an email so I will extend your trial period.
Why doesn't knapsack free use the same way of loading rake tasks?
knapsack gem is older project than knapsack_pro hence the differences.
Ah OK, that still didn't resolve my issue, so I think my problem is unrelated to binstubs. I'll open a new issue then.