I have make installed, I have the riscv32-unknown-linux-gnu toolchain installed.

I have added riscv/bin to my path. I can successfully execute any of the toolchain commands in the shell. e.g. riscv32-unknown-linux gnu-as ... hello.s -o boot.o works.

When i run which riscv32-unknown-linux-gnu-as, there is nothing printed to the terminal.

When I run make in the directory of my makefile i get

riscv32-unknown-linux-gnu-as -march=rv32i -mabi=ilp32 hello.s -o hello.o
make: riscv32-unknown-linux-gnu-as: Command not found
Makefile:18: recipe for target 'hello.o' failed
make: *** [hello.o] Error 127

It seems this is a problem with my path? I'm not sure why which and make can't find it, but I can execute it just fine.

** EDIT **


export PATH="~/riscv/bin:$PATH"

The only thing I can think of is something with the path is weird, this is on WSL

  • Did you add that directory to your PATH by editing you shell's startup files (which one), or did you just add it for the current session by modifying PATH on the command line, or both?
    – Kusalananda
    Nov 8, 2019 at 20:51
  • @Kusalananda it is in my .profile Nov 8, 2019 at 20:52
  • @Kusalananda you can see my edits. Nov 8, 2019 at 20:54
  • Did you also adjust the path in the Makefile ? export PATH := /absolute/path/to/your/home/dir/riscv/bin:$(PATH) should do it
    – Garo
    Nov 8, 2019 at 20:59
  • Remove the double quotes from that assignment to PATH in .profile, or use $HOME rather than ~, or set SHELL=/bin/bash in your Makefile. I'm sure there's a duplicate question somewhere on the site...
    – Kusalananda
    Nov 8, 2019 at 21:01

1 Answer 1


The tilde character (~) does not usually expand to your home directory when it is used within double quotes. If you look at your $PATH value, you will see that it contains a literal tilde, not the full path to you home directory (which it would have done if you hadn't double quoted the value in the assignment).

The shell that make uses to execute shell commands (/bin/sh, which may be the dash shell), and your which command, does not do an extra tilde expansion step on the values in $PATH. This is why both make and which fail to find that command that you need to use.

The bash shell, on the other hand, does an extra tilde expansion step when examining the $PATH, so this is why you can use that command on the command line.

In this scenario, it is bash which is the odd one out, as utilities are not required to expand the tilde when they are using the $PATH variable.


  1. Use $HOME rather than ~ in your .profile. $HOME always behaves like a normal variable.

  2. Don't quote the value in the assignment (it's not needed anyway).

  3. Make make use bash for running the shell commands in the Makefile by setting the make variable SHELL to the path of the bash executable on your system (I would not do this as I would argue that it's the value of you $PATH that is wrong, not the /bin/sh shell's handling of it).

Further reading:

Also note that since PATH is already exported (it's an environment variable), you never have to export it in your shell's startup files.

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .