Skip to content
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

command not found: gn #11

Open
chrisgauthier9 opened this issue Jan 5, 2021 · 2 comments
Open

command not found: gn #11

chrisgauthier9 opened this issue Jan 5, 2021 · 2 comments

Comments

@chrisgauthier9
Copy link

chrisgauthier9 commented Jan 5, 2021

I've been trying to compile ### skia on my Mac running Catalina 10.15.7.

I've gotten to the step:
$ gn gen out/Release-x64 --args="is_debug=false is_official_build=true skia_use_system_expat=false skia_use_system_icu=false skia_use_system_libjpeg_turbo=false skia_use_system_libpng=false skia_use_system_libwebp=false skia_use_system_zlib=false skia_use_sfntly=false skia_use_freetype=true skia_use_harfbuzz=true skia_pdf_subset_harfbuzz=true skia_use_system_freetype2=false skia_use_system_harfbuzz=false target_cpu=\"x64\" extra_cflags=[\"-stdlib=libc++\", \"-mmacosx-version-min=10.9\"] extra_cflags_cc=[\"-frtti\"]"

But I've been getting the following error:
$ command not found: gn

Any ideas??

@ralgernon
Copy link

A Bit of Background

GN is what generates the build files for Ninja. In the terminal, we've been typing or pasting in commands to run different executable files which the shell of our operating system then reads and executes. Our operating system has a variable called $PATH where it keeps a list of directories of all these files, separated by a colon. This resets every time your computer restarts or there's a new terminal instance.

Where to Look

When curious about what that list looks like, I like to use the echo command in the terminal like so:
echo $PATH

We'll see something like /usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin, which are the usual suspects for where to find commands. We edit this using export. In the Aseprite Mac OS instructions, we used:
export PATH="${PWD}/depot_tools:${PATH}"

Which can be translated to:

"Dear shell,
Please check the directories in the $PATH variable list for a command called export.
Execute that to include the depot_tools directory found in the present working directory (PWD, which directory this command is being called from) in my $PATH at the beginning. I want this directory searched first for commands until I close this terminal or restart my computer. Finally, put back all the directories that were in the $PATH list at the end, so you know where else to look if a command isn't found in depot_tools."

The Problem

Your shell has replied that it couldn't find gn in all the directories listed in $PATH, which should have included where the depot_tools was installed after running the above command from the /home/your_user_name/deps directory. When you run echo $PATH, before the first colon should be /home/your_user_name/deps/depot_tools with your actual user name substituted in, so your shell checks the first directory cloned with Git.

Troubleshoot

ls ~/deps/depot_tools/ | grep gn
This command will ask your shell to print all files whose names contain "gn" inside the correct directory. If you get a gn in your response, move ahead to the PATH section. If nothing shows up, run:
ls ~/deps | grep depot_tools
to make sure depot_tools was installed in the right place. If nothing again, you might have missed the step to cd (change directories) to the newly made deps and installed depot_tools and skia to your home directory by accident. The following commands will copy them from home ("~") to the deps directory and delete the misplaced originals:
cp -R ~/depot_tools deps && rm -rf ~/depot_tools
cp -R ~/skia deps && rm -rf ~/skia

PATH to Success

Hopefully you are in the /home/your_user_name/deps/ directory. You can check with:
pwd
Run this command again:
export PATH="${PWD}/depot_tools:${PATH}"
and check again that the first entry matches /home/your_user_name/deps/depot_tools with:
echo $PATH

I don't think it's important to clear out the wrong entries, they'll be gone after the terminal window is closed. The shell checks directories in the same order they are listed in the $PATH and when it finds what it wants.

Success!

You can now change directories back to the skia one with:
cd skia
Skip running the python script again, and try running the command that starts with gn again! If it worked, you'll see something like:
Done. Made 60 targets from 44 files in 121ms

Hopefully this helps!

@nixgoat
Copy link

nixgoat commented May 6, 2021

I have the same issue on my musl libc install of Void Linux.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants