onepub-dev / dcli

An extensive library and tooling for building console/cli applications and scripts using the Dart programming language.
242 stars 28 forks source link

dcli install fails when run as sudo due to pub not being on the path. #112

Closed bsutton closed 4 months ago

bsutton commented 4 years ago

We are now trying to force dcli to be run as sudo.

The first hurdle is that after doing a pub global activate of dcli you don't actually have a compiled script. Instead pub creates a script in pub-cache/bin which launches 'pub run dcli'.

So when we try to run dcli install as sudo the script starts but then can't find pub on the sudo path.

This is a little bit of a catch 22 as we need to be running sudo to add pub to the sudo path.

Of course the reason that pub hasn't been added to the sudo path is because running pub a sudo will screw up the pub-cache.

So plan be could be that dcli install doesn't require sudo to start. It then compiles dcli to an exe an installs to the .dcli/bin. We then re-launch dcli install as sudo but this time we are running the dcli exe which doesn't depend on pub.

One problem is that I think dcli calls pub - actually it doesn't appear to.

we want sudo so we can symlink dcli into a path on the sudo path. this doesn't mean we need to run the whole install in sudo just the symlink and we can do this with a native call.

bsutton commented 4 months ago

this is no longer an issue. We provide instructions on how to run dcli_install that mitgate this issue.