Skip to content

build: require administrator elevation #370

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

Closed
devversion opened this issue Mar 30, 2016 · 13 comments
Closed

build: require administrator elevation #370

devversion opened this issue Mar 30, 2016 · 13 comments

Comments

@devversion
Copy link
Member

Hey, I recently switched back to Windows and now I've noticed that massive build time impact without Administrator Privileges.

I know this bug has been already reported several times and is actually related to the ember-cli project.

So now, I'm asking for something like a feature request. For example, when I use Webstorm's embedded terminal, then I don't have administrator privileges, and that means the build is very slow.

I thought about something like an Administrator Elevation, which will be called, when using the CLI on Windows without administrator privileges.

That means, the default Run as Administrator prompt will appear, and the build can run with elevated permissions.

Not sure, about this being a duplicate, but it should be fine.

@filipesilva
Copy link
Contributor

I'm not really sure there is such a feature in Windows cmd, the equivalent of a su in Linux. Do you know of such a command?

Otherwise I'm not sure how we could programatically elevate the current console.

@devversion
Copy link
Member Author

I didn't implement it myself yet, but I found something which does the desired elevation.

So, the best command flow, would be, to request for permission elevation and then re-execute the given CLI command.

But this seems to be a bit weird:

  • You need to sync the new process with the main process

Additionally, you're depending on some .NET libraries, which is also not very nice.

@anode7
Copy link

anode7 commented Apr 13, 2016

The equivalent of a su in windows is runas
runas /user:<localmachinename>\administrator cmd

I 'm not sure whether applicable here

@filipesilva
Copy link
Contributor

@devversion as far as I can, the second option is doing the same as what @anode7 suggested.

The elevate method in node-windows is interesting though... I can see it working, it's basically a admin level exec. It would require some work to put in, but it should be doable.

I can't say it's a priority right now, but I'll leave the issue open for when there is a bit more time.

@samherrmann
Copy link

I'm coming in fresh here and did not investigate why admin privileges are needed, but is there no option to stay away from needing admin privileges altogether? I'm working in a workplace environment where getting admin rights on my machine will be tough to get...I'm probably not the only one who would face issues with needing admin rights.

@alexkibler
Copy link

@samherrmann I believe admin privileges are because the broccoli-typescript compiler creates symbolic links as part of the compilation process, and symbolic links can't be created without administrator privileges, or at least group policy changes, as per Ember's guide: http://ember-cli.com/user-guide/#symlinks-on-windows

@cwmrowe
Copy link

cwmrowe commented May 20, 2016

I am in the same situation as @samherrmann, i.e. its very unlikely I'm going to be allowed the privileges for creating symlinks (but I am fighting for them!). In the ember guide link above it says:

If symlinks are not available plugins should fall back to copying files

As we don't want to exclude corporate environments perhaps this is the best solution.

@alexkibler
Copy link

@samherrmann and @cwmrowe , check out this post:

#641 (comment)

It's a bit hacky, but if you replace line 206 of node_modules/angular-cli/lib/broccoli-typescript with the following, it will fall back to copying files to a lib folder in the root of your project.

try {
  fs.symlinkSync(absoluteFilePath, outputFilePath);
} catch(e) {
  const conentStr = fs.readFileSync(absoluteFilePath);
  fs.writeFileSync(outputFilePath, conentStr);
}

I've done it and can verify that it works for me. It does significantly slow down the build process (from about 1 second on my personal laptop to about 25 seconds on my work desktop, although there's a huge difference in specs between the machines too), but it works just fine otherwise.

You'll still get the message about not having admin, but it'll work.

@cwmrowe
Copy link

cwmrowe commented May 20, 2016

cheers @alexkibler, that got me most of the way but you also need to add that same bit of code to line 81 of the same file if you want ng serve to work. My vanilla project takes about 8 seconds to build the first time around and then 2 seconds on subsequent builds.

It's also worth mentioning that I the node_modules folder you need to edit is the project one, not the global one.

Do you know if this code will be included in the CLI?

@alexkibler
Copy link

@cwmrowe Great point, you definitely want to modify the project-level folder. Interesting that you had to change line 81 because mine works without changing it.

I hope it ends up getting included, as we'll have to re-patch it every time the CLI team pushes an update.

@alexkibler
Copy link

Just wanted to report in and say that I had our infrastructure lead give me rights to create symlinks, and it is working. My build time went down from 30-ish seconds to 13.

@JasonGoemaat
Copy link

Anyone know the impact of exception handling on speed? I just created a '_useSymlink' property I set to true in the constructor and set to false on the first error, then I just do the copy if it is false instead of the symlink from then on...

devCrossNet pushed a commit to devCrossNet/universal-cli that referenced this issue Jun 9, 2016
In case of non-admin user instead of symlinkSync will just writeFileSync.

Close angular#905
Fix angular#886
Fix angular#370
@angular-automatic-lock-bot
Copy link

This issue has been automatically locked due to inactivity.
Please file a new issue if you are encountering a similar or related problem.

Read more about our automatic conversation locking policy.

This action has been performed automatically by a bot.

@angular-automatic-lock-bot angular-automatic-lock-bot bot locked and limited conversation to collaborators Sep 5, 2019
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

No branches or pull requests

7 participants