You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
When running rails code from outside the rails root, it should still work.
Actual behavior:
It errors because of the package json check:
vendor/bundle/ruby/3.3/gems/package_json-0.1.0/lib/package_json.rb:25:in `read': $DIR does not contain a package.json (PackageJson::Error)
from vendor/bundle/ruby/3.3/gems/shakapacker-8.0.2/lib/shakapacker/utils/manager.rb:19:in `error_unless_package_manager_is_obvious!'
from vendor/bundle/ruby/3.3/gems/shakapacker-8.0.2/lib/shakapacker/railtie.rb:20:in `block in <class:Engine>'
from vendor/bundle/ruby/3.3/gems/railties-7.1.3.4/lib/rails/initializable.rb:32:in `instance_exec'
from vendor/bundle/ruby/3.3/gems/railties-7.1.3.4/lib/rails/initializable.rb:32:in `run'
from vendor/bundle/ruby/3.3/gems/railties-7.1.3.4/lib/rails/initializable.rb:61:in `block in run_initializers'
from /usr/local/lib/ruby/3.3/tsort.rb:231:in `block in tsort_each'
from /usr/local/lib/ruby/3.3/tsort.rb:353:in `block (2 levels) in each_strongly_connected_component'
from /usr/local/lib/ruby/3.3/tsort.rb:434:in `each_strongly_connected_component_from'
from /usr/local/lib/ruby/3.3/tsort.rb:352:in `block in each_strongly_connected_component'
from /usr/local/lib/ruby/3.3/tsort.rb:350:in `each'
from /usr/local/lib/ruby/3.3/tsort.rb:350:in `call'
from /usr/local/lib/ruby/3.3/tsort.rb:350:in `each_strongly_connected_component'
from /usr/local/lib/ruby/3.3/tsort.rb:229:in `tsort_each'
from /usr/local/lib/ruby/3.3/tsort.rb:208:in `tsort_each'
from vendor/bundle/ruby/3.3/gems/railties-7.1.3.4/lib/rails/initializable.rb:60:in `run_initializers'
from vendor/bundle/ruby/3.3/gems/railties-7.1.3.4/lib/rails/application.rb:426:in `initialize!'
from config/environment.rb:12:in `<top (required)>'
from <internal:/usr/local/lib/ruby/3.3/rubygems/core_ext/kernel_require.rb>:136:in `require'
from <internal:/usr/local/lib/ruby/3.3/rubygems/core_ext/kernel_require.rb>:136:in `require'
from test/test_helper.rb:25:in `<top (required)>'
(at least this fixes it for me - of course you might not what the dependency to rails here, but rather in the railtie..).
Btw. self.guess_binary seems to have the same issue, it looks for the lockfile in the current directory instead of the rails root.
On the other hand, Shakapacker::VersionChecker::NodePackageVersion.package_json_path finds the correct package.json, so maybe error_unless_package_manager_is_obvious should use that instead?
The text was updated successfully, but these errors were encountered:
Expected behavior:
When running rails code from outside the rails root, it should still work.
Actual behavior:
It errors because of the package json check:
test_helper.rb:25 contains
Small, reproducible repo:
Should be easy to set up, just init a rails repo, lets say in "reproducer", then add a ruby file one level up with the following content:
Setup environment:
I think the issue is in
This should be something along the lines of
(at least this fixes it for me - of course you might not what the dependency to rails here, but rather in the railtie..).
Btw. self.guess_binary seems to have the same issue, it looks for the lockfile in the current directory instead of the rails root.
On the other hand, Shakapacker::VersionChecker::NodePackageVersion.package_json_path finds the correct package.json, so maybe error_unless_package_manager_is_obvious should use that instead?
The text was updated successfully, but these errors were encountered: