OK, so /snap/bin is in your PATH, but it’s the last path to be checked. So, if Hugo is installed as both a snap and a deb package, running which hugo will show /usr/bin/hugo.
If both are installed properly, whereis hugo should display:
hugo: /usr/bin/hugo /snap/bin/hugo
If I were you, I would uninstall both and start over:
sudo apt remove hugo
sudo snap remove hugo
sudo snap install hugo
which hugo
hugo version
I’m not sure about that. I tried to run your commands. At least it shows the current version of hugo:
/snap/bin/hugo version
hugo v0.121.2-6d5b44305eaa9d0a157946492a6f319da38de154+extended linux/amd64 BuildDate=2024-01-05T12:21:15Z VendorInfo=snap:0.121.2
Hm … which hugo still gives me /snap/bin/hugo.
I get the same error when I try hugo version
I also tried to create an alias (if I understand your command correctly) with alias hugo='/usr/bin/hugo' and when I check with type hugo I do correctly get hugo is aliased to '/usr/bin/hugo'
But I still get the same error when I try hugo version
The strangest thing. I tried to open my terminal now a day later and typed in hugo version as the first thing. And suddenly I don’t get the error but this output:
hugo v0.121.2-6d5b44305eaa9d0a157946492a6f319da38de154+extended linux/amd64 BuildDate=2024-01-05T12:21:15Z VendorInfo=snap:0.121.2
I am also able to continue the Quick start guide and have now progressed to setting up a most basic website on my localhost with a bit of test content.
Do you think it might be the existence of the alias that made this possible after all - and it only worked after I had opened a new terminal? Might this cause problems for me in the future so that I should be cautious going forward because I might have to undo a lot of things as I start building a website?
Exec paths, hashes, and your PATH env variable are pretty basic Linux concepts. The fact that you are having problems with them makes me distrust your setup.
I met the same situation that @malte had, and the problem was solved naturally itself.
At first, I open a terminal (Let’s say T1) and have a apt version of hugo already installed.
In order to install the snap version of hugo, I followed the instructions above by runnning the following commands:
sudo apt remove hugo
sudo apt autoremove libsass1
which hugo
snap search hugo
sudo snap install hugo
which hugo
hugo version
echo $PATH
whereis hugo
/snap/bin/hugo version
type hugo
Click to expand the log
hwhsu1231@vb-kubuntu:~$ sudo apt remove hugo
正在讀取套件清單... 完成
正在重建相依關係... 完成
正在讀取狀態資料... 完成
The following package was automatically installed and is no longer required:
libsass1
Use 'sudo apt autoremove' to remove it.
下列套件將會被【移除】:
hugo
升級 0 個,新安裝 0 個,移除 1 個,有 1 個未被升級。
此操作完成之後,會空出 49.6 MB 的磁碟空間。
是否繼續進行 [Y/n]? [Y/n] y
(讀取資料庫 ... 目前共安裝了 350640 個檔案和目錄。)
正在移除 hugo (0.92.2-1ubuntu0.1)……
執行 man-db (2.10.2-1) 的觸發程式……
hwhsu1231@vb-kubuntu:~$ sudo apt autoremove libsass1
正在讀取套件清單... 完成
正在重建相依關係... 完成
正在讀取狀態資料... 完成
下列套件將會被【移除】:
libsass1
升級 0 個,新安裝 0 個,移除 1 個,有 1 個未被升級。
此操作完成之後,會空出 3,130 kB 的磁碟空間。
是否繼續進行 [Y/n]? [Y/n] y
(讀取資料庫 ... 目前共安裝了 350593 個檔案和目錄。)
正在移除 libsass1:amd64 (3.6.5-1ubuntu1)……
執行 libc-bin (2.35-0ubuntu3.6) 的觸發程式……
hwhsu1231@vb-kubuntu:~$ which hugo
hwhsu1231@vb-kubuntu:~$ snap search hugo
Name Version Publisher Notes Summary
hugo 0.123.8 hugo-authors - A fast and flexible static site generator
bissetii 1.8.0 zoralab - This package bissetii provides a way to install its Go themes.
gotham v0.13.0 gothamhq - An awesome and super fast Static Site Generator.
quiqr 0.15.2 pimsnel - Hugo Powered CMS
demo-hugo-site 0.1 ryanjyoder - Demo Hugo Site - Snap a hugo site
hwhsu1231@vb-kubuntu:~$ sudo snap install hugo
hugo 0.123.8 from Hugo Authors installed
hwhsu1231@vb-kubuntu:~$ which hugo
/snap/bin/hugo
hwhsu1231@vb-kubuntu:~$ hugo version
bash: /usr/bin/hugo: No such file or directory
hwhsu1231@vb-kubuntu:~$ echo $PATH
/home/hwhsu1231/gems/bin:/home/hwhsu1231/.local/bin:/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin:/usr/games:/usr/local/games:/snap/bin:/home/hwhsu1231/.local/share/JetBrains/Toolbox/scripts
hwhsu1231@vb-kubuntu:~$ whereis hugo
hugo: /snap/bin/hugo
hwhsu1231@vb-kubuntu:~$ /snap/bin/hugo version
hugo v0.123.8-5fed9c591b694f314e5939548e11cc3dcb79a79c+extended linux/amd64 BuildDate=2024-03-07T13:14:42Z VendorInfo=snap:0.123.8
hwhsu1231@vb-kubuntu:~$ type hugo
hugo is hashed (/usr/bin/hugo)
hwhsu1231@vb-kubuntu:~$
We can see that hugo version command failed, and the output of the last step type hugo is:
hugo is hashed (/usr/bin/hugo)
However, if I open a new terminal (Let’s say T2), and then run the following commands:
which hugo
hugo version
type hugo
Click to expand the log
hwhsu1231@vb-kubuntu:~$ which hugo
/snap/bin/hugo
hwhsu1231@vb-kubuntu:~$ hugo version
hugo v0.123.8-5fed9c591b694f314e5939548e11cc3dcb79a79c+extended linux/amd64 BuildDate=2024-03-07T13:14:42Z VendorInfo=snap:0.123.8
hwhsu1231@vb-kubuntu:~$ type hugo
hugo is hashed (/snap/bin/hugo)
We can see that the hugo version works for T2 terminal, and the output of the type hugo is now:
hugo is hashed (/snap/bin/hugo)
And then, I go back to the T1 terminal, and then run the following commands:
type hugo
hash -d hugo
type hugo
hugo version
Click to expand the log
hwhsu1231@vb-kubuntu:~$ type hugo
hugo is hashed (/usr/bin/hugo)
hwhsu1231@vb-kubuntu:~$ hash -d hugo
hwhsu1231@vb-kubuntu:~$ type hugo
hugo is /snap/bin/hugo
hwhsu1231@vb-kubuntu:~$ hugo version
hugo v0.123.8-5fed9c591b694f314e5939548e11cc3dcb79a79c+extended linux/amd64 BuildDate=2024-03-07T13:14:42Z VendorInfo=snap:0.123.8
We can see that the hugo version works for T1 terminal as well, and the output of type hugo is now:
hugo is /snap/bin/hugo
Can you explain this phenomenon and conclude this topic?