Running "jspm install" task fails "Unable to read current working directory"

migajek's Avatar

migajek

17 May, 2016 11:01 AM

Hi,
running "jspm install" command via MSBuild fails as mentioned

here's my configuration

<Target Name="NpmBuild" BeforeTargets="CompileTypeScriptWithTSConfig" Condition=" '$(Configuration)' == 'Release' ">
    <Exec Command="npm install" />
    <Message Text="Npm install finished" />

    <Exec Command="npm install jspm -g" />
    <Message Text="Npm install jspm global finished" />

    <Exec Command="npm install gulp -g" />
    <Message Text="Npm install gulp global" />

    <Exec Command="npm install typings@0.8.1 -g" />
    <Message Text="Npm install typings global" />
    

    <Exec Command="%USERPROFILE%\AppData\Roaming\npm\typings.cmd install" />
    <Message Text="Typings Build Finished" />

    <Exec Command="%USERPROFILE%\AppData\Roaming\npm\jspm.cmd install" />
    <Message Text="JSPM Build Finished" />
  </Target>

it fails with multiple errors, saying:

(NpmBuild target) ->
         EXEC : error : fatal: Unable to read current working directory: No error [D:\temp\kmreogmz.via\input\XXXXX.Web\XXXXX.Web.csproj]
         EXEC : error : fatal: Unable to read current working directory: No error [D:\temp\kmreogmz.via\input\XXXXX.Web\XXXXX.Web.csproj]
         EXEC : error : fatal: Unable to read current working directory: No error [D:\temp\kmreogmz.via\input\XXXXX.Web\XXXXX.Web.csproj]
         EXEC : error : fatal: Unable to read current working directory: No error [D:\temp\kmreogmz.via\input\XXXXX.Web\XXXXX.Web.csproj]
         EXEC : error : fatal: Unable to read current working directory: No error [D:\temp\kmreogmz.via\input\XXXXX.Web\XXXXX.Web.csproj]
         EXEC : error : fatal: Unable to read current working directory: No error [D:\temp\kmreogmz.via\input\XXXXX.Web\XXXXX.Web.csproj]
         EXEC : error : fatal: Unable to read current working directory: No error [D:\temp\kmreogmz.via\input\XXXXX.Web\XXXXX.Web.csproj]
         EXEC : error : fatal: Unable to read current working directory: No error [D:\temp\kmreogmz.via\input\XXXXX.Web\XXXXX.Web.csproj]
         D:\temp\kmreogmz.via\input\XXXXX.Web\XXXXX.Web.csproj(397,5): error MSB3073: The command "%USERPROFILE%\AppData\Roaming\npm\jspm.cmd install" exited with code 1.

  1. Support Staff 1 Posted by rune on 24 May, 2016 02:01 AM

    rune's Avatar

    Hi,

    Apologies for the slow response. Did you figure this one out in the meantime? I took a look at your apps and the only app with recent builds that succeeded. If you resolved it and have time it'd be great if you could share what the solution was (might be helpful to others).

    Otherwise let me know the name of the application and ideally a link to a build failing with this error.

    Best,
    Rune

  2. 2 Posted by migajek on 24 May, 2016 07:04 AM

    migajek's Avatar

    Hi Rune,

    Thank you for the reply.
    I haven't solved the problem, what I did is a temporary (hopefully) workaround - I've removed the "frontend" build steps from the MSBuild, and instead deploy bundled files via git.

    I've created a branch and an application to demonstrate the problem, however this time the error is different (even though the code is the same) - has anything changed in the build environment in the meantime?

    Here is the failing build
    https://appharbor.com/applications/nb-failing/builds/1748224

  3. Support Staff 3 Posted by rune on 25 May, 2016 04:00 AM

    rune's Avatar

    Hi again,

    Yep the build servers was updated with a slightly newer version of Git, which fortunately included more descriptive error messages and revealed the underlying cause of this (and other related npm/grunt/bower) related issues -- take a look at my response in this thread for a description of the cause and a solution.

    It should work for this issue as well, although you may have to execute the NPM package script from a different directory (or initialize the Git repository so it doesn't attempt to traverse the directory structure beyond your user profile directory).

    Best,
    Rune

  4. 4 Posted by migajek on 27 May, 2016 08:10 PM

    migajek's Avatar

    Hi Rune,
    thank you for the reply again.
    I've tried executing "git init" before npm/jspm install, however had no luck again - the same "permission denied" error appeared.

    I'm trying to reproduce it locally, copied over my package.json + config.js (jspm dependencies) to a temporary directory (which is not a git repo) and ran the same sequence as msbuild runs ... and it all installed correctly.

    I have no idea why would git try to traverse the directory tree upward on the AppHb server ?

  5. Support Staff 5 Posted by rune on 28 May, 2016 01:41 AM

    rune's Avatar

    Hi,

    Ok sorry this is still causing you trouble. About the git traversal: That's just how git works -- for instance, if you're in a subdirectory of your git repository and execute git status it'll still be able to identify that the subfolder is a part of the git repository. Since there are no git files in subfolders of a repository this can only work by traversing the directory structure until a git repository folder (.git) is found.

    I took a look at some of the more recent builds on one of the related applications. It looks like the git repository is being initialized now, but the permission error is still there. That's likely because the git repository is being initialized in the temporary folder created for your builds, but the npm packages are installed on under the user profile for the application.

    You could try and remove the "-g" switch from the NPM install commands so it's not installed globally. This should (or did, in the other discussion I linked to) cause the packages to be installed under the build context directory and address the git traversal issue.

    I'd admit that this is a bit of a hack and it's very likely that there's a way to prevent npm from attempting to traverse repositories or use git in this way. If you figure out a more elegant way I'd love to hear what your solution is!

    Best,
    Rune

Discussions are closed to public comments.
If you need help with AppHarbor please start a new discussion.

Keyboard shortcuts

Generic

? Show this help
ESC Blurs the current field

Comment Form

r Focus the comment reply box
^ + ↩ Submit the comment

You can use Command ⌘ instead of Control ^ on Mac