-
Notifications
You must be signed in to change notification settings - Fork 2.6k
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
npm install task (not msbuild) fails with EPERM on hosted build #323
Comments
the front page of the agent repo talks about the npm issue |
Front page talks about installing vsoagent, but I have that issue on hosted pool/agent while running npm install task during build? |
Ahhh. interesting. Are you installing from npm globally? (-g) |
I don't think so. I just add Npm Install task to my build and setup working directory to folder where is my package.json |
I have the same problem with 'Npm install' build step on Visual Studio Online using hosted pool agent to build. |
OK - we will investigate today |
Hey guys, sorry you're hitting this issue. I think I see what the problem is, it should be resolved shortly. Thanks, |
Closing since the fix is about to rollout to hosted |
Re-opening for Dennis to confirm |
It looks like my original theory wasn't correct. Can either of you provide me your visualstudio.com account name so I can look up which data center you're account is in? You can email me at [email protected] if you're uncomfortable posting it here. Other questions that may help us diagnose the issue: Does the step fail for all npm packages or just certain ones? If so, which have you seen it succeed for and which failed? Thanks, |
Hi, My VSO account name is rcs-pol. For the first time I used 'npm install' build step yesterday and I had these problems from this first time. The only successful step was about 3 hours ago. I thought you had solved the problem. However now this step fails again. Error from build log: |
Our theory is currently this: http://stackoverflow.com/questions/26491311/lock-file-gets-in-the-way-when-trying-to-generate-yeoman-chrome-extension If that is the issue, we need to update npm on our build image |
I've gotten this issue randomly as well. I've run into an issue previously where if multiple builds that call "npm install" run at the same time, the lock file from the first npm install will cause the second one to fail. I didn't have much time to try and fix the issue with NPM and ended up only being able to limit builds to one concurrent NPM install at once. I did read that you can override the global cache folder per run using --cache=/folder but didn't get much farther on it. |
We're you running multiple agents on the same machine (that might be another workaround). Interesting that you can set cache folder - we could set local to each agent. Although it seems like it's npm's job to protect's it's cache. We'll look at the workaround. thx |
I think local to each agent would be the best bet. My specific use case was with Jenkins and multiple agents but the idea was the same. |
This happened to me too. A quick solution was to make a agent for a Linux machine already set up. The problem is that we have no control over the npm. Eg: One of the things that can put an end to these problems will be docker support , which will give us control of the environment even in the hosted environment. |
Also having the same issues here, I have been unable to use
|
The image with this fix went out on Friday/Monday. Are you still seeing the permission issue? |
@thechrisjohnson Yes, I just queued up another build and still got the same failure message.
Anything else you need from me to investigate further? |
I'm unable to repro this issue just running npm install on a test project I have. What packages are you trying to install when this occurs? |
@thechrisjohnson It works on my machine, but only fails when running the build in VSO using the Hosted Build Controller. |
Oh, this is a xaml based build? |
Can you provide a package.json file that repros that we can try? From: Werner van Deventer [mailto:[email protected]] @thechrisjohnsonhttps://github.com/thechrisjohnson It works on my machine, but only fails when running the build in VSO using the Hosted Build Controller. — |
@thechrisjohnson Just some simple MSBUILD <Project ToolsVersion="12.0" DefaultTargets="GulpBuild" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
...
<PropertyGroup>
<CompileDependsOn>
$(CompileDependsOn);
GulpBuild;
</CompileDependsOn>
</PropertyGroup>
...
<Target Name="GulpBuild">
<Exec Command="if not exist C:\Users\buildguest\AppData\Roaming\npm mkdir C:\Users\buildguest\AppData\Roaming\npm" />
<Exec Command="npm install" />
<Exec Command="node_modules\.bin\bower install" />
<Exec Command="gulp release" />
</Target> Deploy copy steps and so forth omitted since it can't get past the You can use any packages I guess, it fails with different names on each build so it appears random as to when exactly it fails. Here is a sample of my {
"name": "MyProject",
"private": "true",
"version": "0.0.1",
"description": "",
"dependencies": {},
"devDependencies": {
"bower": "^1.4.1",
"browser-sync": "^2.7.12",
"del": "~1.2.0",
"gulp": "^3.9.0",
"gulp-autoprefixer": "~2.3.1",
"gulp-concat": "~2.5.2",
"gulp-consolidate": "~0.1.2",
"gulp-csso": "~1.0.0",
"gulp-declare": "~0.3.0",
"gulp-ext-replace": "^0.2.0",
"gulp-foreach": "^0.1.0",
"gulp-handlebars": "^4.0.0",
"gulp-hb": "^2.6.0",
"gulp-if": "~1.2.5",
"gulp-imagemin": "~2.2.1",
"gulp-jsbeautifier": "0.0.8",
"gulp-jshint": "~1.11.0",
"gulp-load-plugins": "~0.10.0",
"gulp-minify-html": "~1.0.3",
"gulp-minify-inline": "^0.1.0",
"gulp-newer": "~0.5.0",
"gulp-ng-annotate": "^1.0.0",
"gulp-plumber": "~1.0.1",
"gulp-print": "~1.1.0",
"gulp-sass": "^2.0.3",
"gulp-uglify": "~1.2.0",
"gulp-usemin": "~0.3.11",
"gulp-wrap": "~0.11.0",
"imagemin-jpegtran": "^4.2.0",
"imagemin-pngquant": "~4.1.0",
"jshint-stylish": "~2.0.0",
"merge-stream": "^0.1.7",
"run-sequence": "~1.1.1"
}
} |
Thanks! I was able to repro the issue and will push out a fix within the next day or so. |
Awesome! Let me know when it's done and I'll give it a test. |
It would also be good to try the same thing from the new build system (+ definition from the web view) |
I've tried to run my orginal build (based on new build system) and now NPM part works. |
@Bartmax - the npm bug is a race condition that repros on windows with low I/O. This isn't a CI issue - I sent npm a repro (way up in the thread) with a package.json and npm cmd line (no CI involved). We just run cmd line just like Travis. Travis also doesn't build on windows. And yes, as I pointed out in the thread way above, there's an inexpensive workaround which is to pass --force as additional args to npm. That causes it to bypass the cache which avoids the race and deep graphs with multiple writes without locking to the cache dir ( npm/npm#9696 ). We are considering just doing that on hosted (with retries like other CIs do) since it's always a fresh machine and the cache doesn't help much. |
We're getting this error using the NPM task (with --force) on our self-hosted instance consistently (we just set it up in the last couple of days):
Is there any other way to get this working? |
@tghamm - npm is writing to the cache folder: EPERM: operation not permitted, rename 'C:\Users\tfsbuild\AppData\Roaming\npm-cache ... Which implies --force is not being passed (force fetches and bypassed the cache) Can you:
|
@bryanmacfarlane will do. It's actually working intermittently now so I'm waiting for it to fail again. |
Using the "--force" works for now but is far from an optimal solution. We're trying to roll out a rather large pipeline using npm right now and I'm afraid this might get a serious issue. |
@konrad-ha - agreed. The only right fix is npm fixing the race condition. --force, retries, and faster I/O are all workarounds/mitigations. |
How about a focused hackathon by Microsoft dedicated to fix this for |
I have been running my own VSO agent on a VM with premium storage data disk for 10 days and even though it dramatically improves the situation (and build times) - I still see the occasional EPERM error (very rare though so far) |
what about a central cache/disk for npm in the microsoft infrastructure. Instead of downloading everything, the vm can attach the cache drive and download there or use it as cache improving speed by a lot and prevent this kind of errors. (same can be done for nuget). if the vm is run without cache (some option?), no disk will be attached and you can opt in for the current behavior (for those needing that stuff actually gets downloaded) Personally, It will make me very happy to use hosted agent and don't waste download speed / bandwidth. |
Our team city agents also run into this issue. Using the --force argument does not work unfortunately. Here is a sample build log:
Our agents are running on Windows 7 and currently it is not feasible to upgrade the agents to use an SSD... |
Lots of progress in finding the root issue from Microsoft open tech. The issue is in npm2. More here: npm/npm#9696 The good news is it's fixed in npm3 ([sudo] npm install npm@3). We're progressing to see if a fix can be pushed to npm2. We are looking to move hosted build pool to npm3 and we're almost done with premium storage in the hosted pool (even if npm3 fixes, still much faster I/O). So to sum up the workarounds:
|
Very cool! |
Based on this thread, I may have found a workaround: first install npm@3, then run that using a Command Line task to do the actual npm install:
My npm install tasks finished successfully without having to restart it multiple times for the first time in months! |
@Maarten88 +1 |
Hosted build image is getting npm3 this sprint. Note that if you have your own agent and you install npm3 (or node5.x) and it resolves in your path (confirm with npm -v), then you can use the npm task (no need use command line task but that's fine as well). |
We had to roll back npm3 because it broke Cordova so it will be a bit longer before we can move to it. From: Bryan MacFarlane [mailto:[email protected]] Hosted build image is getting npm3 this sprint. Note that if you have your own agent and you install npm3 (or node5.x) and it resolves in your path (confirm with npm -v), then you can use the npm task (no need use command line task but that's fine as well). — |
What is the progress on this? Would it help to simply include node_modules into the repository and basically skip the npm install? Is it a good idea? |
I would not do that. You kind of break the concept behind npm install. npm install npm@3 takes usually less than 2 minutes for us. npm install of course has to download quite some stuff (depending on project), but thats the point, to keep the dependencies up to date and to latest release. |
Progress: Microsoft open tech fixed the root problem in npm2. When that is released, we will update our hosted image to it. On your machines you can do the same or install npm@3 We are also in the process of rolling out premium storage disks to our hosted pool scale units at no cost to our customers. Early numbers show significant I/O gains and have cut the time in half for some of our sample builds. This will minimize the likelyhood of hitting the bug. This upcoming sprint, we will offer a drop down in the npm task to specify which npm version. It will be leveraging a tools concept we will be adding: https://github.com/Microsoft/vso-agent-tasks/blob/master/docs/tools.md |
Good news Bryan and thanks to MS open tech. Will there be an announcement on a blog somewhere when the upcoming sprint is deployed? Better yet would be a note here, it would be fantastic for those subscribed to this thread. -Paul |
Thanks for the information. If I understand you correctly: when using the Hosted Agent, we need to wait until the fix is released. However, the upcoming sprint will bring some improvements sooner and the fix will be released a bit later. |
There has been some time from the last comment so i was wondering has there been any progress on this issue ? The workaround that @Maarten88 posted works fine, but it would be much cleaner if VSO would provide different versions of npm out of the box. I was wondering if the dropdown version selection will as well apply to node and other dependencies or is it only npm for now ? |
Closing. It was confirmed as an npm2 bug and the fix was made to npm2 |
It looks like there are some problems with permissions while installing various packages over
npm install
.When I run my build for the 1st time I received the following errors:
After that I just run my build for the 2nd time without any modifications and I got the following errors:
I receiving that errors on VSO
The text was updated successfully, but these errors were encountered: