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

EPERM with browserify on Windows, succeeds with browserify-incremental #195

Open
zrisher opened this issue Mar 28, 2017 · 1 comment
Open

Comments

@zrisher
Copy link

zrisher commented Mar 28, 2017

Hi all,

Thanks for this awesome gem.

I'm having a bit of trouble precompiling my assets on Windows 10. rake assets:precompile works fine in development and test, but rake assets:precompile RAILS_ENV=production always fails:

c:\path\to\app>rake assets:precompile RAILS_ENV=production --trace
** Invoke assets:precompile (first_time)
** Invoke assets:environment (first_time)
** Execute assets:environment
** Invoke environment (first_time)
** Execute environment
** Execute assets:precompile
rake aborted!
BrowserifyRails::BrowserifyError: Error while running `c:/apps/zanobo/tadpole_site/node_modules/.bin/browserify -t [ babelify --presets [ es2015 ] ] -o "c:/apps/zanobo/tadpole_site/tmp/cache/browserify-rails/output20170327-7824-14q4fx5" -`:

Error: EPERM: operation not permitted, rename 'c:\path\to\app\tmp\cache\browserify-rails\output20170327-7824-14q4fx5.tmp-browserify-82482803762211620580' -> 'c:\path\to\app\tmp\cache\browserify-rails\output20170327-7824-14q4fx5'
C:/dev/ruby/Ruby23-x64/lib/ruby/gems/2.3.0/gems/browserify-rails-4.1.0/lib/browserify-rails/browserify_processor.rb:221:in `run_browserify'
C:/dev/ruby/Ruby23-x64/lib/ruby/gems/2.3.0/gems/browserify-rails-4.1.0/lib/browserify-rails/browserify_processor.rb:52:in `call'
C:/dev/ruby/Ruby23-x64/lib/ruby/gems/2.3.0/gems/browserify-rails-4.1.0/lib/browserify-rails/browserify_processor.rb:16:in `call'
...

There's tons of issues visible from Google that detail people encountering this issue when running any number of node.js programs (Medium/phantomjs#19, browserify/watchify#83, npm/npm#10826), and it usually has to do with other processes locking the files (anti-virus, IDES, etc). I disabled all these, restarted, ran npm cache clean, and deleted my app's tmp folder. No dice.

Since this only occurs in production, I hoped to narrow down the issue. Even after replacing config/environments/production with a copy of config/environments/development this still occurs. I scanned my app for other configuration differences that might occur and found none. I scanned this app for other configuration differences and found this in the railtie:

config.browserify_rails.use_browserifyinc = !["staging", "production"].include?(Rails.env)

As I expected, setting config.browserify_rails.use_browserifyinc = true in config/environments/production.rb fixed this issue. In fact, I can then remove this line and the command still works until I delete the tmp folder, at which point it reappears.

I know this repo isn't the place for browserify support, and Windows issues are annoying, but I thought the difference behavior between the two programs might help someone more familiar with these tools point me in the right direction. Does anyone know why switching config.browserify_rails.use_browserifyinc fixes this issue, and what I might do to fix it in a more permanent way?

browserify-rails (4.1.0)
ruby 2.3.3p222 (2016-11-21 revision 56859) [x64-mingw32]
package.json:

{
  "engines": {
    "node": ">= 7.3.3"
  },
  "dependencies": {
    "babel-preset-es2015": "^6.24.0",
    "babelify": "^7.3.0",
    "browserify": "^14.1.0"
  }
}
@cymen
Copy link
Member

cymen commented Feb 7, 2018

That is odd. The good news is using browserifyinc in production shouldn't cause any problems. It is just disabled because it's mostly to make rebuilds faster and in production it's usually a fresh build each time and browserifyinc is slightly slower for the initial build. Or can be.

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