Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Wrong lookup path #196

Open
pointlessone opened this issue Apr 24, 2017 · 6 comments
Open

Wrong lookup path #196

pointlessone opened this issue Apr 24, 2017 · 6 comments

Comments

@pointlessone
Copy link

Hello,

I'm experience an issue in an app I didn't develop but I want to deploy.

My setup is Rails 5 app with broowserify-rails 4.1.0. I'm deploying the app with Capistrano.

It's a typical capistrano layout:

  • /var/www/app
    • releases
      • 123
        • node_modules -> /var/www/app/shared/node_modules
        • public
          • assets -> /var/www/app/shared/public/assets
    • shared
      • node_modules
      • public
        • assets

I'm getting an error like this:

BrowserifyRails::BrowserifyError: Error while running `/var/www/app/releases/123/node_modules/.bin/browserify --transform babelify --extension=".jsx" --list -o "/var/www/app/releases/123/tmp/cache/browserify-rails/output20170424-28084-u5l9bm" -`:

events.js:163
      throw er; // Unhandled 'error' event
      ^

Error: Cannot find module '../../../../../shared/node_modules/is-buffer/index.js' from '/var/www/app/shared/node_modules/http-link-header/lib'
    at /var/www/appshared/node_modules/resolve/lib/async.js:55:21
    at load (/var/www/app/shared/node_modules/resolve/lib/async.js:69:43)
    at onex (/var/www/app/shared/node_modules/resolve/lib/async.js:92:31)
    at /var/www/app/shared/node_modules/resolve/lib/async.js:22:47
    at FSReqWrap.oncomplete (fs.js:114:15)
Ruby backtrace
/var/www/app/shared/bundle/ruby/2.4.0/gems/browserify-rails-4.1.0/lib/browserify-rails/browserify_processor.rb:221:in `run_browserify'
/var/www/app/shared/bundle/ruby/2.4.0/gems/browserify-rails-4.1.0/lib/browserify-rails/browserify_processor.rb:144:in `dependencies'
/var/www/app/shared/bundle/ruby/2.4.0/gems/browserify-rails-4.1.0/lib/browserify-rails/browserify_processor.rb:121:in `commonjs_module?'
/var/www/app/shared/bundle/ruby/2.4.0/gems/browserify-rails-4.1.0/lib/browserify-rails/browserify_processor.rb:93:in `should_browserify?'
/var/www/app/shared/bundle/ruby/2.4.0/gems/browserify-rails-4.1.0/lib/browserify-rails/browserify_processor.rb:35:in `call'
/var/www/app/shared/bundle/ruby/2.4.0/gems/browserify-rails-4.1.0/lib/browserify-rails/browserify_processor.rb:16:in `call'
/var/www/app/shared/bundle/ruby/2.4.0/gems/sprockets-3.7.1/lib/sprockets/processor_utils.rb:75:in `call_processor'
/var/www/app/shared/bundle/ruby/2.4.0/gems/sprockets-3.7.1/lib/sprockets/processor_utils.rb:57:in `block in call_processors'
/var/www/app/shared/bundle/ruby/2.4.0/gems/sprockets-3.7.1/lib/sprockets/processor_utils.rb:56:in `reverse_each'
/var/www/app/shared/bundle/ruby/2.4.0/gems/sprockets-3.7.1/lib/sprockets/processor_utils.rb:56:in `call_processors'
/var/www/app/shared/bundle/ruby/2.4.0/gems/sprockets-3.7.1/lib/sprockets/loader.rb:134:in `load_from_unloaded'
/var/www/app/shared/bundle/ruby/2.4.0/gems/sprockets-3.7.1/lib/sprockets/loader.rb:60:in `block in load'
/var/www/app/shared/bundle/ruby/2.4.0/gems/sprockets-3.7.1/lib/sprockets/loader.rb:317:in `fetch_asset_from_dependency_cache'
/var/www/app/shared/bundle/ruby/2.4.0/gems/sprockets-3.7.1/lib/sprockets/loader.rb:44:in `load'
/var/www/app/shared/bundle/ruby/2.4.0/gems/sprockets-3.7.1/lib/sprockets/cached_environment.rb:20:in `block in initialize'
/var/www/app/shared/bundle/ruby/2.4.0/gems/sprockets-3.7.1/lib/sprockets/cached_environment.rb:47:in `load'
/var/www/app/shared/bundle/ruby/2.4.0/gems/sprockets-3.7.1/lib/sprockets/bundle.rb:23:in `block in call'
/var/www/app/shared/bundle/ruby/2.4.0/gems/sprockets-3.7.1/lib/sprockets/utils.rb:200:in `dfs'
/var/www/app/shared/bundle/ruby/2.4.0/gems/sprockets-3.7.1/lib/sprockets/bundle.rb:24:in `call'
/var/www/app/shared/bundle/ruby/2.4.0/gems/sprockets-3.7.1/lib/sprockets/processor_utils.rb:75:in `call_processor'
/var/www/app/shared/bundle/ruby/2.4.0/gems/sprockets-3.7.1/lib/sprockets/processor_utils.rb:57:in `block in call_processors'
/var/www/app/shared/bundle/ruby/2.4.0/gems/sprockets-3.7.1/lib/sprockets/processor_utils.rb:56:in `reverse_each'
/var/www/app/shared/bundle/ruby/2.4.0/gems/sprockets-3.7.1/lib/sprockets/processor_utils.rb:56:in `call_processors'
/var/www/app/shared/bundle/ruby/2.4.0/gems/sprockets-3.7.1/lib/sprockets/loader.rb:134:in `load_from_unloaded'
/var/www/app/shared/bundle/ruby/2.4.0/gems/sprockets-3.7.1/lib/sprockets/loader.rb:60:in `block in load'
/var/www/app/shared/bundle/ruby/2.4.0/gems/sprockets-3.7.1/lib/sprockets/loader.rb:317:in `fetch_asset_from_dependency_cache'
/var/www/app/shared/bundle/ruby/2.4.0/gems/sprockets-3.7.1/lib/sprockets/loader.rb:44:in `load'
/var/www/app/shared/bundle/ruby/2.4.0/gems/sprockets-3.7.1/lib/sprockets/cached_environment.rb:20:in `block in initialize'
/var/www/app/shared/bundle/ruby/2.4.0/gems/sprockets-3.7.1/lib/sprockets/cached_environment.rb:47:in `load'
/var/www/app/shared/bundle/ruby/2.4.0/gems/sprockets-3.7.1/lib/sprockets/base.rb:66:in `find_asset'
/var/www/app/shared/bundle/ruby/2.4.0/gems/sprockets-3.7.1/lib/sprockets/base.rb:73:in `find_all_linked_assets'
/var/www/app/shared/bundle/ruby/2.4.0/gems/sprockets-3.7.1/lib/sprockets/manifest.rb:142:in `block in find'
/var/www/app/shared/bundle/ruby/2.4.0/gems/sprockets-3.7.1/lib/sprockets/legacy.rb:114:in `block (2 levels) in logical_paths'
/var/www/app/shared/bundle/ruby/2.4.0/gems/sprockets-3.7.1/lib/sprockets/path_utils.rb:228:in `block in stat_tree'
/var/www/app/shared/bundle/ruby/2.4.0/gems/sprockets-3.7.1/lib/sprockets/path_utils.rb:212:in `block in stat_directory'
/var/www/app/shared/bundle/ruby/2.4.0/gems/sprockets-3.7.1/lib/sprockets/path_utils.rb:209:in `each'
/var/www/app/shared/bundle/ruby/2.4.0/gems/sprockets-3.7.1/lib/sprockets/path_utils.rb:209:in `stat_directory'
/var/www/app/shared/bundle/ruby/2.4.0/gems/sprockets-3.7.1/lib/sprockets/path_utils.rb:227:in `stat_tree'
/var/www/app/shared/bundle/ruby/2.4.0/gems/sprockets-3.7.1/lib/sprockets/legacy.rb:105:in `each'
/var/www/app/shared/bundle/ruby/2.4.0/gems/sprockets-3.7.1/lib/sprockets/legacy.rb:105:in `block in logical_paths'
/var/www/app/shared/bundle/ruby/2.4.0/gems/sprockets-3.7.1/lib/sprockets/legacy.rb:104:in `each'
/var/www/app/shared/bundle/ruby/2.4.0/gems/sprockets-3.7.1/lib/sprockets/legacy.rb:104:in `logical_paths'
/var/www/app/shared/bundle/ruby/2.4.0/gems/sprockets-3.7.1/lib/sprockets/manifest.rb:140:in `find'
/var/www/app/shared/bundle/ruby/2.4.0/gems/sprockets-3.7.1/lib/sprockets/manifest.rb:185:in `compile'
/var/www/app/shared/bundle/ruby/2.4.0/gems/sprockets-rails-3.2.0/lib/sprockets/rails/task.rb:68:in `block (3 levels) in define'
/var/www/app/shared/bundle/ruby/2.4.0/gems/sprockets-3.7.1/lib/rake/sprocketstask.rb:147:in `with_logger'
/var/www/app/shared/bundle/ruby/2.4.0/gems/sprockets-rails-3.2.0/lib/sprockets/rails/task.rb:67:in `block (2 levels) in define'
/var/www/app/shared/bundle/ruby/2.4.0/gems/rake-12.0.0/exe/rake:27:in `'
/home/deployer/.rvm/gems/ruby-2.4.1@app/gems/bundler-1.14.6/lib/bundler/cli/exec.rb:74:in `load'
/home/deployer/.rvm/gems/ruby-2.4.1@app/gems/bundler-1.14.6/lib/bundler/cli/exec.rb:74:in `kernel_load'
/home/deployer/.rvm/gems/ruby-2.4.1@app/gems/bundler-1.14.6/lib/bundler/cli/exec.rb:27:in `run'
/home/deployer/.rvm/gems/ruby-2.4.1@app/gems/bundler-1.14.6/lib/bundler/cli.rb:335:in `exec'
/home/deployer/.rvm/gems/ruby-2.4.1@app/gems/bundler-1.14.6/lib/bundler/vendor/thor/lib/thor/command.rb:27:in `run'
/home/deployer/.rvm/gems/ruby-2.4.1@app/gems/bundler-1.14.6/lib/bundler/vendor/thor/lib/thor/invocation.rb:126:in `invoke_command'
/home/deployer/.rvm/gems/ruby-2.4.1@app/gems/bundler-1.14.6/lib/bundler/vendor/thor/lib/thor.rb:359:in `dispatch'
/home/deployer/.rvm/gems/ruby-2.4.1@app/gems/bundler-1.14.6/lib/bundler/cli.rb:20:in `dispatch'
/home/deployer/.rvm/gems/ruby-2.4.1@app/gems/bundler-1.14.6/lib/bundler/vendor/thor/lib/thor/base.rb:440:in `start'
/home/deployer/.rvm/gems/ruby-2.4.1@app/gems/bundler-1.14.6/lib/bundler/cli.rb:11:in `start'
/home/deployer/.rvm/gems/ruby-2.4.1@app/gems/bundler-1.14.6/exe/bundle:32:in `block in '
/home/deployer/.rvm/gems/ruby-2.4.1@app/gems/bundler-1.14.6/lib/bundler/friendly_errors.rb:121:in `with_friendly_errors'
/home/deployer/.rvm/gems/ruby-2.4.1@app/gems/bundler-1.14.6/exe/bundle:24:in `'
/home/deployer/.rvm/gems/ruby-2.4.1@app/bin/bundle:22:in `load'
/home/deployer/.rvm/gems/ruby-2.4.1@app/bin/bundle:22:in `'
/home/deployer/.rvm/gems/ruby-2.4.1@app/bin/ruby_executable_hooks:15:in `eval'
/home/deployer/.rvm/gems/ruby-2.4.1@app/bin/ruby_executable_hooks:15:in `'
Tasks: TOP => assets:precompile
(See full trace by running task with --trace)

If you take a closer look at the module path it tries to find there seem to be one extra ... Without it I can find the file on disk.

I searched on the web and can't find anything like this. I myself have no experience with either browserify. Please advice how to fix this issue. Please let me know if you need any additional information.

@cymen
Copy link
Member

cymen commented Apr 25, 2017

Are you building assets for production? Typically, one would and browserify-rails wouldn't be trying to build the asset bundle in production. Something like this might be helpful:

http://stackoverflow.com/questions/17767995/understating-how-assets-in-rails-4-work-in-production

Other things to try are making sure modules are up to date -- so I'd look at http-link-header and it's dependencies (which you can easily see on npmjs.org).

@pointlessone
Copy link
Author

I'm precompiling assets as a part of deployment process.
I'm running more or less this command:

RAILS_ENV=production bundle exec rake assets:precompile

The command is ran from the app directory (/var/www/app/releases/123).

As you can see in the Ruby backtrace, browserify-rails is invoked.

@cymen
Copy link
Member

cymen commented Apr 25, 2017

What happens if you run that same command in the root of your development environment? I think your deploy has funky path issues due to your versioning. Bit of a wild guess but would be good to rule out early.

@pointlessone
Copy link
Author

I can not reproduce this on my local machine (macOS) both with symlinked and real node_modules. On the server (Linux) though, if I have a real directory the command succeeds. It fails with symlinked node_modules.

@cymen
Copy link
Member

cymen commented Apr 25, 2017

I think you're running into something like this capistrano/rails#51. I don't use Capistrano so I'm not sure how to fix it.

@pointlessone
Copy link
Author

Thanks for the link. I'll take a look a bit later.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants