I'm getting errors on running pact-mock-service:
D:\dev\H-D\VTS\Vts.Passon\Vts.Passon\WebApp>node_modules\@pact-foundation\pact-mock-service\node_modules\.bin\pact-mock-service.cmd --port "1234" --host "localhost" --pact_dir "D:\dev\H-D\VTS\Vts.Passon\Vts.Passon\WebApp\pacts"
Ignoring json-2.1.0 because its extensions are not built. Try: gem pristine json --version 2.1.0
D:/dev/H-D/VTS/Vts.Passon/Vts.Passon/WebApp/node_modules/@pact-foundation/pact-mock-service/node_modules/@pact-foundation/pact-mock-service-win32/lib/ruby/lib/ruby/2.2.0/rubygems/core_ext/kernel_require.rb:54:in `require': cannot load such
file -- bundler/vendor/molinillo/lib/molinillo/modules/specification_provider (LoadError)
from D:/dev/H-D/VTS/Vts.Passon/Vts.Passon/WebApp/node_modules/@pact-foundation/pact-mock-service/node_modules/@pact-foundation/pact-mock-service-win32/lib/ruby/lib/ruby/2.2.0/rubygems/core_ext/kernel_require.rb:54:in `require'
...etc...
I think the root cause is that the file it is trying to load is past 260 characters in path length:
D:\dev\H-D\VTS\Vts.Passon\Vts.Passon\WebApp\node_modules\@pact-foundation\pact-mock-service\node_modules\@pact-foundation\pact-mock-service-win32\lib\ruby\lib\ruby\gems\2.2.0\gems\bundler-1.9.9\lib\bundler\vendor\molinillo\lib\molinillo\modules\specification_provider.rb
The path is 271 characters long, so I'm guessing something in Ruby isn't letting it load since it's past the MAX_PATH length.
From just the \node_modules to the file, is 227 characters, plus 3 more for the drive letter, that's only allowing 30 characters for the project path.
This initially also affected @pact-foundation/pact-provider-verifier-win32 because it was nested underneath @pact-foundation/pact-provider-verifier's node_modules, but I deleted and rebuilt my root node_modules directory and it npm moved it up a layer.
I was getting testing failures:
> jest --config jest.pact.config.js
[2017-07-11T22:14:26.637Z] INFO: [email protected]/68172 on XXXXXXXX: Creating Pact with PID: 68852
ERROR: The process "68852" not found.
ERROR: The process "68852" not found.
RUNS test/TisStore.pact.ts
child_process.js:524
throw err;
^
Error: Command failed: taskkill /f /t /pid 68852
ERROR: The process "68852" not found.
at checkExecSyncError (child_process.js:481:13)
at Object.execSync (child_process.js:521:13)
at Server.Object.<anonymous>.Server.stop (D:\dev\H-D\VTS\Vts.Passon\Vts.Passon\WebApp\node_modules\@pact-foundation\pact-node\src\server.js:138:7)
at Server.<anonymous> (D:\dev\H-D\VTS\Vts.Passon\Vts.Passon\WebApp\node_modules\@pact-foundation\pact-node\src\server.js:117:8)
at ChildProcess.g (events.js:292:16)
at emitTwo (events.js:106:13)
at ChildProcess.emit (events.js:191:7)
at maybeClose (internal/child_process.js:891:16)
at Socket.<anonymous> (internal/child_process.js:342:11)
at emitOne (events.js:96:13)
npm ERR! code ELIFECYCLE
npm ERR! errno 1
npm ERR! [email protected] test:pact: `jest --config jest.pact.config.js`
npm ERR! Exit status 1
npm ERR!
npm ERR! Failed at the [email protected] test:pact script.
I was trying to troubleshoot, and one of the previous issues asked if the underlying services could run, so that's where I got to the above issue.
As an experiment, could you try installing and running it from a very short home path. eg D:\t\ ?
I looked into npm's documentation and they mentioned npm dedupe. I ran that twice to get it to move the pact-mock-service-win32 directory up a couple levels. The tests work now.
Is there any way that it could just work on install?
@ngbrown is the code always running on windows? dev test and prod?
@mboudreau is it possible to just install the pact-mock-service-win32 package directly? This would cut out a fair amount of the path.
Yes, I'm only working with Windows.
I believe the pact-mock-service npm package is just a wrapper that chooses which underlying package to install (win32, darwin, linux...) so if you're just using windows all the time, you should be able to directly install the windows package.
A part of me wants to say "it's 2017, how the f**k is this still a problem" but that wouldn't be constructive...
On the dedupe, I'm not sure if we can selectively dedupe just this package, and running the dedupe during postinstall is not something I'm willing to do as it could bring a whole new class of issues (see https://github.com/npm/npm/issues/6912). Perhaps there is an alternative installation approach, I'm open to suggestions if it helps this issue.
If it didn't have to be in a npm namespace, that would free up a bunch of characters:
\node_modules\@pact-foundation\pact-mock-service\node_modules\@pact-foundation\pact-mock-service-win32\
@pact-foundation\ times two is 34 characters.
I'm not a node person, but I have noticed that all the node modules I use don't have namespaces. Why are we using one?
Is this an acceptable answer ¯_(ツ)_/¯ ?
I jest. But as you can see, we _don't_ use it for the actual pact package
However there has been discussions internally amongst the various pact
contributors that there are some inherent values in having modules behind a
namespace - trust.
Angular and other major projects do this, so that you can differentiate
supported modules from third-party ones (you also get some organisation
level functions in the registry we publish to). This seems like a good idea
in theory and the only downside is that you have to type a little more when
you install a dependency.
However, as we can see - the downside for Windows is dire. Perhaps this is
an option.
I've also been wanting to merge much of the functionality from pact-node
into this project at some point - perhaps that time is closer than we
think...
Does that mean we could get rid of one layer of dependency? That sounds like a good idea.
Three, actually. This is the current dependency chain - pact -> @pact-foundation/pact-node -> @pact-foundation/pact-mock-service-npm -> @pact-foundation/pact-mock-service-npm-<osarch>.
It is in theory possible and I'm looking into how we do it. The way we wrap Ruby under the hood is via optional dependencies, where node works out which optional dependency to install based on os/arch. We could use the postinstall hook of the package to execute a shell script which pulls the specific ruby-standalone binary and installs them locally.
I'm having the same problem after cloning the repository and trying to run the tests on windows. I've tried running npm dedupe but the pact-mock-service-win32 isn't moved any higher and still lives at pact-js-master\node_modules\@pact-foundation\pact-node\node_modules\@pact-foundation\pact-mock-service\node_modules\@pact-foundation\pact-mock-service-win32\bin
Is there any way of 'forcing' the child node_module directories up to the top level?
The pact-js folder is located at C:\Users\C51072\code\ which I can't make much shorter because of restrictions on my work laptop.
I am able to start the pact-mock-service when I manually move the pact-mock-service-win32 folder to a shorter directory, but not from the default directory
Edit: Running dedupe after upgrading to the latest version of npm resolve the problem
@gseabrook not that I'm aware of, sorry.
@mboudreau FYI this is another reason to do away with the two extra libraries and look to reduce our dependency tree.
@mefellows yes.
On Wed, Aug 23, 2017 at 8:28 AM Matt Fellows notifications@github.com
wrote:
@gseabrook https://github.com/gseabrook not that I'm aware of, sorry.
@mboudreau https://github.com/mboudreau FYI this is another reason to
do away with the two extra libraries and look to reduce our dependency tree.—
You are receiving this because you were mentioned.Reply to this email directly, view it on GitHub
https://github.com/pact-foundation/pact-js/issues/64#issuecomment-324169542,
or mute the thread
https://github.com/notifications/unsubscribe-auth/AAjA5KmCzu1bIJLtYaccdPutndH_ff6Oks5sa1YcgaJpZM4OU8bV
.
Closing this issue. We have migrated this package to @pact-foundation and simultaneously reduced the path length by increasing the pact-node package size (long story in https://github.com/pact-foundation/pact-node/issues/42 ad https://github.com/pact-foundation/pact-node/issues/42#issuecomment-336602638).