Nemo64 / meteor-bootstrap

Highly configurable bootstrap integration for meteor.
https://atmospherejs.com/nemo64/bootstrap
167 stars 27 forks source link

ENOENT, no such file or directory #5

Closed gerwinbrunner closed 10 years ago

gerwinbrunner commented 10 years ago

In a brand new meteor 0.9.1.1 project I added bootstrap (meteor add nemo64:bootstrap) and followed the instructions to get it running.

In custom.bootstrap.json I set everything to true.

Now when I run meteor every thing works nicely. Also when I run meteor bundle xxx.

Now when I check in the project and check it back out on a second computer and I run meteor bundle xxx I get the following error:

Errors prevented bundling:
While building the application:
fs.js:432:18: ENOENT, no such file or directory '.meteor/local/build/programs/server/assets/packages/nemo64:bootstrap/bootstrap/js/transition.js' (compiling client/stylesheets/vendor/custom.bootstrap.json)
  at Object.fs.openSync (fs.js:432:18)
  at Object.fs.readFileSync (fs.js:289:15)
  at getAsset (<runJavaScript-31>:192:15)
  at handler (<runJavaScript-31>:267:16)

Any idea what this causes and how to fix it?

gerwinbrunner commented 10 years ago

Very strange...

When I start the app on the second computer with meteor it throws the same error. After quoting it and restarting it with meteor it starts up correctly. After that I also can run meteor bundle xxx

Any idea why this happens?

Nemo64 commented 10 years ago

Only guesses. This package needs Access to his assets while building assets. This is not provided by meteor which is why it reads the javascript files with readFileSync instead of Assets.getText. To be sure, you should always run the app using meteor first and then try to bundle it.

Because this is related to the build plugin, you tar bundle should not be affected later, as the build plugin isn't included there.

gerwinbrunner commented 10 years ago

@Nemo64 I was thinking something like this would be the case. This is kind of a bummer... I was trying to get CI running and I'm not able to just build the meteor app without starting the server...

gerwinbrunner commented 10 years ago

This seems to be the functionality you are talking about. It'll come in meteor 0.9.2 hopefully.

https://github.com/meteor/meteor/issues/2488 and https://github.com/meteor/meteor/issues/2506

pauldowman commented 10 years ago

FWIW this error seems to always happen on 0.9.2-rc5, I can't get it to work at all. Reverting to 0.9.1.1 and deleting .meteor/local seems to fix it.

pauldowman commented 10 years ago

My previous comment was incorrect. I think I've narrowed it down to something reproducible though: this error happens after doing meteor reset (on 0.9.1 or 0.9.2-rc*).

pauldowman commented 10 years ago

Also, the workaround is:

  1. Delete the contents of custom.bootstrap.json (just make it empty, don't delete the whole file)
  2. Restart the app, which will replace the contents of custom.bootstrap.json
  3. Now set custom.bootstrap.json the way you want it (git co custom.bootstrap.json or at least delete the semicolon).
pauldowman commented 10 years ago

Oh and BTW @Nemo64 thanks for your work. :-D

vjau commented 10 years ago

I had the same problem @pauldowman, my custom.bootstrap.json was pulled from a git repository from another computer.... the installer seems to not like that. I blanked the file, then let the build process refill it, then put back the correct settings and it works.

Rorto commented 10 years ago

Hi, same kind of problem for me, but after blanked the custom.bootstrap.json it's still impossible to deploy. Sorry to bother you with my error log (a bit different than OP) :

Errors prevented deploying:
While building the application:
fs.js:432:18: ENOENT, no such file or directory '.meteor/local/build/programs/server/assets/packages/nemo64:bootstrap/bootstrap/js/transition.js' (compiling client/stylesheets/vendor/custom.bootstrap.json)
  at Object.fs.openSync (fs.js:432:18)
  at Object.fs.readFileSync (fs.js:289:15)
  at getAsset (packages/bootstrap-configurator/bootstrap-configurator.js:14)
  at handler (packages/bootstrap-configurator/bootstrap-configurator.js:89)
pauldowman commented 10 years ago

Yeah I think I just discovered the same as @Rorto, that workaround works locally but it's impossible to deploy.

Neobii commented 10 years ago

Since updating to 9.2 i'm getting the same error as Rorto after trying that workaround. God save us.

ghost commented 10 years ago

Same here... downgraded to 0.9.1 for now!

henryj commented 10 years ago

I can see the folder has been renamed in 0.9.2 where it used to be .meteor/local/build/programs/server/assets/packages/nemo64:bootstrap/bootstrap/js/transition.js now it's .meteor/local/build/programs/server/assets/packages/nemo64_bootstrap/bootstrap/js/transition.js.

So nemo64:bootstrap -> nemo64_bootstrap. Maybe just change that in bootstrap-configurator.js will fix the problem.

lacco commented 10 years ago

+1 for fixing this, this error occurs for me also after upgrading to Meteor 0.9.2 .

tanis2000 commented 10 years ago

@Nemo64 it happens to me as well. It's something that has to do with the official 0.9.2 release of Meteor.

@henryj is right about the path. All of the colons get replaced by underscores in 0.9.2.. if you're using the package name in the path, this will lead to the error we see down there:

=> Errors prevented startup:

While building the application:
fs.js:432:18: ENOENT, no such file or directory '.meteor/local/build/programs/server/assets/packages/nemo64:bootstrap/bootstrap/js/transition.js' (compiling client/less/custom.bootstrap.json)
  at Object.fs.openSync (fs.js:432:18)
  at Object.fs.readFileSync (fs.js:289:15)
  at getAsset (packages/bootstrap-configurator/bootstrap-configurator.js:14)
  at handler (packages/bootstrap-configurator/bootstrap-configurator.js:89)

=> Your application has errors. Waiting for file change.
chemuto commented 10 years ago

+1. Same problem updating to 0.9.2

garrilla commented 10 years ago

+1 Same problem after 0.9.2.1

myknbani commented 10 years ago

Thanks, now I can upgrade ^_^

Nemo64 commented 10 years ago

Well the only thing fixed is actually the new version, the problem with with the first build still exists. I currently have no solution for it.

Rorto commented 10 years ago

Thanks but it's still impossible to deploy with nemo64:bootstrap 3.2.1 and Meteor 0.9.2.1 for me. Error log is the same as before. I don't understand why.

pauldowman commented 10 years ago

There are multiple issues here. One is that 0.9.2 changed the : to _, thanks to @tanis2000 for fixing that.

The other issue still exists: if .meteor/local doesn't exist (e.g. after doing meteor reset, or after a clean checkout) then we get the same error when starting the local server or when doing meteor build.

It seems like a timing issue actually, I noticed that the file actually does exist when I check right after the error happens, and restarting the local app works.

I can deal with that workaround locally, but there's no workaround when deploying to any system that does a checkout and build locally (rather than just receiving a pre-built tar.gz file), e.g. Heroku.

tanis2000 commented 10 years ago

@Nemo64 I digged a bit about this issue and it looks like that when you call getAsset through getLessContent('bootstrap/less/mixins.less') the entire .meteor/local/build folder is still completely empty (at least in my test project).

I don't know if there's a way too get notified when the assets from the package have been copied or if there's another hook that we can attach to so that it gets called later.

elie222 commented 10 years ago

Getting the same problem in 0.9.1.1. Unable to fix it even trying the suggestions above.

petrometro commented 10 years ago

+1, and tanis2000 that looks exactly like the trouble i'm having

tanis2000 commented 10 years ago

I've opened an issue at the Meteor repo: https://github.com/meteor/meteor/issues/2606

It looks like there is no way around this problem with the current version of Meteor.

pauldowman commented 10 years ago

Yeah, I looked into this too and I can't see how it fix it. I don't think reading from .meteor/local can work for meteor build in the general case (pulling from you development cached assets to build for production is probably not a good idea even if it can be done), so there needs to be some other way for a package to access it's own files, and I don't think there's an official way at the moment.

Nemo64 commented 10 years ago

There isn't an official way in general for this. I have some Ideas though. It may do something if the bootstrap package is in the use list of the build plugin (maybe it builds all assets then before). Another (even more hackier) solution would be to compile all assets into json js files and add them as souce to the build plugin. That are my current ideas but again, i don't have enough time on weekdays.

tanis2000 commented 10 years ago

@Nemo64 the second is a true workaround and a lot of effort for little gain when MDG could just change something in the build tool and make everything easier. But your approach will probably work.

As far as I can tell, it's only the line Plugin.registerSourceHandler('bootstrap.json', {archMatching: 'web'}, handler); that triggers the handler function of the package. I checked by printing some stuff to the console from within the package.

It looks like this part of the package.js file does nothing during the app startup:

Package._transitional_registerBuildPlugin({
  name: 'bootstrap-configurator',
  use: ['underscore'],
  sources: [
    'modules.js',
    'distributed-configuration.js',
    'bootstrap-configurator.js'
  ],
  npmDependencies: {}
});
Nemo64 commented 10 years ago

What do you mean by it does nothing? It adds the sources to the bundler. Without it, the sourceHandler wouldn't do anything. Or did there change something?

tanis2000 commented 10 years ago

@Nemo64 I meant that it doesn't trigger anything during the build and there's no way to trigger anything. I thought there might be a way to tell the build tool in which order to execute different steps. As far as I can tell, it's just that the source handler is being called even before the package has been built within the app.

Nemo64 commented 10 years ago

Ahh, I understand. Have you tried my first suggestion? use: ['underscore', 'nemo64:bootstrap'], in the build plugin might trigger the build of the package fist. At best it would be possible to use Assets.getText then.

tanis2000 commented 10 years ago

@Nemo64 lol yeah I tried your first suggestion and I managed to put Meteor in an infinite loop :)

imacvalerio:test-meteor-bootstrap tanis$ meteor
[[[[[ ~/Documents/test-meteor-bootstrap ]]]]]

=> Started proxy.
=> Started MongoDB.
=> Starting your app...
/Users/tanis/.meteor/packages/meteor-tool/.1.0.30.1d7tfbn++os.osx.x86_64+web.browser+web.cordova/meteor-tool-os.osx.x86_64/dev_bundle/lib/node_modules/fibers/future.js:173
                        throw(ex);
                              ^
RangeError: Maximum call stack size exceeded
imacvalerio:test-meteor-bootstrap tanis$
Nemo64 commented 10 years ago

I have another Idea. How about splitting this package. One will only contain the assets and provide an api over Assets.getText and the build plugin uses it then. There are no hacks or deep paths involved then. How does that sound?

tanis2000 commented 10 years ago

I don't know if that would work out of the box. It depends if the dependencies are resolved correctly. In theory that should work.

tanis2000 commented 10 years ago

@Nemo64 did you get a chance at trying this approach? Any news/discoveries?

rdewolff commented 10 years ago

Just noticed, with a blank project, if you create sub folders and save your custom.bootstrap.json to :

/myMeteorProject/client/lib/custom.bootstrap.json

it will generate an error.

I moved the custom.bootstrap.json file back to root in

/myMeteorProject/custom.bootstrap.json

and erased its content. And it worked like a charm.

This seems like a bug.

Nemo64 commented 10 years ago

Did you rm -rf .meteor/local/ before trying again? Becausse after the first error, the bundler generates the required files and on the second try it works.

@tanis2000 I didn't manage to try my idea this weekend, sorry.

tanis2000 commented 10 years ago

It looks like the build output folder shouldn't be accessed by packages at build time. That's the way it's intended to work according to this: https://github.com/meteor/meteor/issues/2606#issuecomment-56590332

Nemo64 commented 10 years ago

Yesterday I managed to play around a bit and found that splitting things up into 2 packages actually seems to work. The sub package can access Assets via Assets.getText and it seems to work immediately without waiting for the second build. I pushed that already in the master but icon-fonts aren't included correctly yet so I cannot release it yet but maybe later today.

tanis2000 commented 10 years ago

Nice one! :)

Nemo64 commented 10 years ago

I admit that I haven't tested it enough but i released it now and it seemed to not break my stuff.

Would be interested if it works everywhere else now ;)

vjau commented 10 years ago

I got following error: While building the application: client/less/custom.bootstrap.less:1736:126: Less compiler error: variable @input-border-radius-small is undefined

vjau commented 10 years ago

I must add that before update, it was working.

Nemo64 commented 10 years ago

can you delete custom.bootstrap.less and custom.bootstrap.mixins.import.less and try again? I just tried with a new meteor project and it's working.

vjau commented 10 years ago

Ok nevermind, i just deleted custom.bootstrap.import.less, put back my settings and now it works. Thank you.

Nemo64 commented 10 years ago

you haven't by any chance checked what has changed?

vjau commented 10 years ago

Between my old custom.bootstrap.import.less and the new autogenerated one ? No, sorry. I just know that the variable @input-border-radius-small was causing the problem. It's defined like that in the custom.bootstrap.import.less: @input-border-radius-small: @border-radius-small; But it's not present anymore in the custom.bootstrap.less

Nemo64 commented 10 years ago

ahhh i think i know what i did wrong. I accidentally cloned the master of bootstrap into bootstrap-data and not the 3.2.0 tag. I probably should fix that asap but i forgot to push the release yesterday :/

tanis2000 commented 10 years ago

@Nemo64 I haven't tried adding it from atmosphere, but if I clone the repo to my packages folder like I already did when trying out different solutions, Meteor complains:

Could not resolve the specified constraints for this package:
Error: unknown package: bootstrap-data

It looks like it's not even taking into consideration the packages folder inside the nemo64:bootstrap folder in the app's packages.