Skip to content

build: require administrator elevation #370

Closed

Description

@devversion

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.

Activity

  1. filipesilva commented on Apr 6, 2016

    @filipesilva
    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.

  2. devversion commented on Apr 6, 2016

    @devversion
    MemberAuthor

    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.

  3. anode7 commented on Apr 13, 2016

    @anode7

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

    I 'm not sure whether applicable here

  4. filipesilva commented on Apr 21, 2016

    @filipesilva
    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.

  5. samherrmann commented on May 19, 2016

    @samherrmann

    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.

  6. alexkibler commented on May 19, 2016

    @alexkibler

    @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

  7. cwmrowe commented on May 20, 2016

    @cwmrowe

    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.

  8. alexkibler commented on May 20, 2016

    @alexkibler

    @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.

  9. cwmrowe commented on May 20, 2016

    @cwmrowe

    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?

  10. alexkibler commented on May 20, 2016

    @alexkibler

    @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.

  11. alexkibler commented on May 20, 2016

    @alexkibler

    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.

  12. JasonGoemaat commented on May 30, 2016

    @JasonGoemaat

    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...

  13. added a commit that references this issue on Jun 1, 2016
    0bc3d94
  14. added a commit that references this issue on Jun 9, 2016
    43089ad
  15. angular-automatic-lock-bot commented on Sep 5, 2019

    @angular-automatic-lock-bot

    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.

  16. locked and limited conversation to collaborators on Sep 5, 2019
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions