dart-lang / sdk

The Dart SDK, including the VM, JS and Wasm compilers, analysis, core libraries, and more.
https://dart.dev
BSD 3-Clause "New" or "Revised" License
10.25k stars 1.58k forks source link

Permission denied on running globally activated dart package. #48675

Open Yousuf-M-Hammad opened 2 years ago

Yousuf-M-Hammad commented 2 years ago

I'm trying to develop a command line package so I followed these steps:

dart create --template=package-simple package_name or dart create -t console-full package_name (Both ends with the same results) then activating the package globally with:

dart pub global activate --source path $(pwd)

note that I didn't find anything in the documentation about --source path actual_path but whenever I use the command only with --source actual_path I get the following:

"/Users/user/Desktop/Workspace/package_name" is not an allowed value for option "source".

So after successfully activating the package I tried to run it using:

package_name

But I got this:

zsh: command not found: package_name

Found out that the documentation here is outdated and after searching the local directory I found the actual directory is global_packages not bin, and so I've changed it.

Now when I try package_name I get: zsh: permission denied: package_name

After investigation I found that package_name is a directory in the global_packages directory and it only contains pubspec.lock so I've tried chmod a+x on the file and the directory with no avail.

Further investigation the global_packages contained another package intl_utils inside I found:

.packages       incremental
.dart_tool      bin             pubspec.lock

But running intl_utils on the terminal too get's me the same error: zsh: permission denied: intl_utils I didn't install the package manually but the VS Code extension Flutter Intl did and it seems to work perfectly fine.

Now I have two questions:

  1. permission denied on what exactly since the Flutter Intl extension works perfectly???
  2. I have a file in my package bin/my_package.dart but it didn't go there, am I doing something wrong?

I'm running dart through flutter: Flutter (Channel master, 2.13.0-0.0.pre.90, on macOS 12.3 21E230 darwin-x64, locale en-US)

dart --version

Dart SDK version: 2.17.0-202.0.dev (dev) (Thu Mar 10 20:55:41 2022 -0800) on "macos_x64"

OS: MacOs Monterey 12.3 (21E230)

Yousuf-M-Hammad commented 2 years ago

So after messing around and changing the branch (a lot) turns out the problem is in the pubspec.yaml where there should be :

executables:
  package_name: # you can add a custom path here if you want though 

And i guess the docs were right about "bin" directory but it left me wondering about global_packages and intl_utils