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

--features=regenerate-css does not work on nightly (Windows 10) #342

Closed
projektir opened this issue Jun 19, 2017 · 12 comments · Fixed by #343
Closed

--features=regenerate-css does not work on nightly (Windows 10) #342

projektir opened this issue Jun 19, 2017 · 12 comments · Fixed by #343
Labels
A-Infrastructure Area: CI, Releases C-dependency-bug Category: A bug in a dependency S-Blocked-Upstream Status: Blocked Upstream

Comments

@projektir
Copy link
Contributor

mdBook uses custom Rust code to detect the presence of packages stylus and nib. From what I can see, it expects to see files stylus.cmd and nib.cmd. While stylus.cmd is created when installing these packages, nib.cmd is not, so the command cargo build --features=regenerate-css does not work and insists that nib is not installed.

I've attempted installing the packages in different order, reinstalling these packages, fiddling with PATH, reinstalling Node, running everything as Administrator and not, etc. None of these actions have produced a nib.cmd file in my C:\Users\<username>\AppData\Roaming\npm folder.

Operating System: Windows 10
Node version: 6.11.0
npm -g list: https://gist.github.com/projektir/96825837c67028eea7d857a7dfb338f8

Is there any kind of workaround for this? Is there some way to force Node to provide me with the requested .cmd files? I don't know how to move past this and therefore work with CSS, which blocks #247.

@azerupi
Copy link
Contributor

azerupi commented Jun 19, 2017

I'm sorry for the trouble!
This has recently been changed to improve the error messages when stylus and nib where not installed but maybe it wasn't correctly tested on all platforms.

@budziq do you know more about this?

@azerupi azerupi added A-Infrastructure Area: CI, Releases C-bug Category: A bug, incorrect or unintended behavior labels Jun 19, 2017
@budziq
Copy link
Contributor

budziq commented Jun 20, 2017

I'll look into it. Althought I do not have access to Win 10 machine neither privately nor at work :/.

The code does not look for nib.cmd (it looks for npm.cmd and stylus.cmd). The nib dependency is checked only if npm list -g nib returns success.

@projektir could you post the full output of

  • cargo build --features=regenerate-css
  • npm list -g nib
  • npm list -g stylus

and information:

  • is npm or npm.cmd in path.
  • is stylus or stylus.cmd in path
  • if any of these are not cmd then what?

If the npm list -g nib or its stylus counterpart just started failing with false positives on Win10 for whatever reason then removing following two lines from build.rs
https://github.com/azerupi/mdBook/blob/master/build.rs#L72
https://github.com/azerupi/mdBook/blob/master/build.rs#L73
should get you going untill the problem is solved.

TLNR;

As a side note. In terms of the cmd stuff. As described in original issue https://github.com/azerupi/mdBook/issues/294 The usage of .cmd files was a workaround for Rust Command PATH finding being problematic rust-lang/rust#37519 as

npm and stylus were represented on Windows as npm.cmd while Command::spawn would append ".exe" but did not test with other executable extensions like cmd, thus Command::new("npm") would expand to Command::new("npm.exe") instead of Command::new("npm.cmd").

If node changed its naming strategy or different executable files are present for npm and stylus we cam try to work around that.

@projektir
Copy link
Contributor Author

projektir commented Jun 20, 2017

Oh, whoops, totally read npm as nib there. My npm.cmd is in C:\Program Files\nodejs and that's definitely in PATH. stylus.cmd is also in PATH. I can call both npm and stylus from the command line, as well, but not nib.

cargo build --features=regenerate-css

λ cargo build --features=regenerate-css
Compiling mdbook v0.0.22-pre (file:///C:/Git/mdBook)
error: failed to run custom build command for mdbook v0.0.22-pre (file:///C:/Git/mdBook)
process didn't exit successfully: C:\Git\mdBook\target\debug\build\mdbook-f8db5b6c54d58571\build-script-build (exit code: 1)
--- stderr
Error: Missing npm package 'nib' install with: 'npm -g install nib'

npm list -g nib

λ npm list -g nib
C:\Users<username>\AppData\Roaming\npm
`-- nib@1.1.2

npm list -g stylus

λ npm list -g stylus
C:\Users<username>\AppData\Roaming\npm
+-- nib@1.1.2
| -- stylus@0.54.5 -- stylus@0.54.5

Also for reference, when I removed the Package("nib").exists()?; line, it started complaining about not finding stylus. When I removed Package("stylus").exists()?;, it threw an error about being unable to find the stylus module. So looks like the problem is deeper than that.

I'm installing Ubuntu on a virtual machine. 😆

@budziq
Copy link
Contributor

budziq commented Jun 20, 2017

I can call both npm and stylus from the command line, as well, but not nib.

Yeah nib is just a library that stylus uses.

Package("stylus").exists()?;, it threw an error about being unable to find the stylus module. So looks like the problem is deeper than that

Hmmm. It looks like there is either a problem with the instalation or npm binary stoped setting proper process exit status.

it threw an error about being unable to find the stylus module. So looks like the problem is deeper than that

Do you have the final error output handy? It might speed things up. It looks like npm cannot find / run stylus + nib internally which might be an installation problem or unlikely regression on their side.

I'm installing Ubuntu on a virtual machine. 😆

Sorry for the problems and thanks for your time!
I'll try to get my hands on win10 box.

Please note that on ubuntu npm and nodejs are installed separately via apt.

@projektir
Copy link
Contributor Author

Note that this is on a relatively fresh install of Windows, and with reinstalled Node with nothing else, so I seriously doubt there's a problem with the installation. Is there a different version of Node/npm worth trying?

Do you have the final error output handy?

Not sure how useful it is:

λ cargo build --features=regenerate-css
Compiling mdbook v0.0.22-pre (file:///C:/Git/mdBook)
error: failed to run custom build command for mdbook v0.0.22-pre (file:///C:/Git/mdBook)
process didn't exit successfully: C:\Git\mdBook\target\debug\build\mdbook-f8db5b6c54d58571\build-script-build (exit code: 1)
--- stderr
module.js:471
throw err;
^

Error: Cannot find module 'C:\Git\mdBook\node_modules\stylus\bin\stylus'
at Function.Module._resolveFilename (module.js:469:15)
at Function.Module._load (module.js:417:25)
at Module.runMain (module.js:604:10)
at run (bootstrap_node.js:389:7)
at startup (bootstrap_node.js:149:9)
at bootstrap_node.js:504:3
Error: Stylus encoutered an error

C:\Git\mdBook\node_modules is empty... should it not be?

@budziq
Copy link
Contributor

budziq commented Jun 20, 2017

I seriously doubt there's a problem with the installation.

I'm inclined to think the same but until I have access to some Win10 box this is my only lead except for changes in OS behaviour or bug in npm.

Is there a different version of Node/npm worth trying?

I'm verifying on Win7 pro and it works ok with following

> npm -v
3.10.10

> node -v 
v6.10.3

> npm list -g nib
`-- nib@1.1.2

> npm list -g stylus
`-- nib@1.1.2
  `-- stylus@0.54.5

C:\Git\mdBook\node_modules is empty... should it not be?

I'm no node_modules is searched only for local instalations and we are explicitely using npm install -g for global. (I've tested with and without the dir anyway with no difference)

I don't know your node version (it is bundled with node anyway) It looks that we can narrow the differences to:

I'm afraid that without access to a win10 box I'll not be able to go further here (I would not like to waste your time with remote debugging session as I've no actual experience with node/npm. I have originally rewritten the build.rs because it failed both on my Arch/Ubuntu and Win7 boxes ;)

Setting appveyor windows 10 build might be worth a shot (but I don't know which windows server version would approximate your setup best).

@budziq
Copy link
Contributor

budziq commented Jun 20, 2017

@projektir

Not sure how useful it is:

Well the output looks like stylus just does not work on your setup as it has problems with internal dependencies.
does following work?

> cd C:\Git\mdBook
> stylus.cmd src\theme\stylus\book.styl --out src\theme --use nib

This is what the actual build.rs boils down to.

@budziq
Copy link
Contributor

budziq commented Jun 20, 2017

@azerupi
I was able to reproduce the problem with appveyor "Visual Studio 2017" image (PR https://github.com/azerupi/mdBook/issues/343).
It fails only on rust nightly on on this appveyor image (I assume that it is the closes to you box ;) )

https://ci.appveyor.com/project/budziq/mdbook/build/1.0.2

rustc -V
rustc 1.19.0-nightly (04145943a 2017-06-19)
cargo -V
cargo 0.21.0-nightly (50b1c24d1 2017-06-17)

---------%<---------------
     Running `rustc --crate-name build_script_build build.rs --crate-type bin --emit=dep-info,link -C debuginfo=2 --cfg "feature=\"crossbeam\"" --cfg "feature=\"default\"" --cfg "feature=\"iron\"" --cfg "feature=\"notify\"" --cfg "feature=\"output\"" --cfg "feature=\"regenerate-css\"" --cfg "feature=\"serve\"" --cfg "feature=\"staticfile\"" --cfg "feature=\"time\"" --cfg "feature=\"watch\"" --cfg "feature=\"ws\"" -C metadata=3122b1842c709ab2 -C extra-filename=-3122b1842c709ab2 --out-dir C:\projects\mdbook\target\debug\build\mdbook-3122b1842c709ab2 -L dependency=C:\projects\mdbook\target\debug\deps --extern error_chain=C:\projects\mdbook\target\debug\deps\liberror_chain-8b19293dfcfc8a3e.rlib`
       Fresh handlebars v0.26.2
       Fresh mount v0.3.0
       Fresh ws v0.7.3
       Fresh staticfile v0.4.0
     Running `C:\projects\mdbook\target\debug\build\mdbook-3122b1842c709ab2\build-script-build`
error: failed to run custom build command for `mdbook v0.0.22-pre (file:///C:/projects/mdbook)`
process didn't exit successfully: `C:\projects\mdbook\target\debug\build\mdbook-3122b1842c709ab2\build-script-build` (exit code: 1)
--- stderr
Error: Missing npm package 'nib' install with: 'npm -g install nib'
Command exited with code 101

Sadly, this is still not reproducible on the same nightly on my Win7 box 😞

@projektir I hope that you are compiling with rust nightly (otherwise I've no more leads).

@projektir
Copy link
Contributor Author

Aaaa, it is a nightly issue! Switched to stable and it works!

Excellent detective work! I forget I'm even on nightly half the time and that it may cause issues.

Interesting that this only fails on Win10, though, no idea what's going on there.

@budziq
Copy link
Contributor

budziq commented Jun 20, 2017

Interesting that this only fails on Win10, though, no idea what's going on there.

Ha, exciting! I'll try to get my hands on a win10 box and debug a little (debugging via appveyor logs is far from painless ;) )

@azerupi I would motion to change this issue title and add a separate issue aimed at adding regenerate-css to appveyor (https://github.com/azerupi/mdBook/issues/343) and travis

@azerupi azerupi changed the title mdBook does not use or detect nib correctly on Windows 10 with Node 6.11.0 --features=regenerate-css does not work on nightly (Windows 10) Jun 20, 2017
@azerupi
Copy link
Contributor

azerupi commented Jun 20, 2017

Done :)
Thanks a lot for looking into this!

@budziq
Copy link
Contributor

budziq commented Jun 21, 2017

@azerupi I've posted the problem upstream rust-lang/rust#42791
I guess that we can mark it as blocked upstream. Don't know if we should merge https://github.com/azerupi/mdBook/pull/343 akready or wait for it to be fixed upstream.

@azerupi azerupi added C-dependency-bug Category: A bug in a dependency S-Blocked-Upstream Status: Blocked Upstream and removed C-bug Category: A bug, incorrect or unintended behavior labels Jun 21, 2017
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
A-Infrastructure Area: CI, Releases C-dependency-bug Category: A bug in a dependency S-Blocked-Upstream Status: Blocked Upstream
Projects
None yet
Development

Successfully merging a pull request may close this issue.

3 participants