我正在按照此处找到的步骤安装DFINITY Canister SDK
.
当我运行以下命令时,不会创建目录dfx
(在/bin
下),随后无法识别dfx
命令:
adel@adel-VirtualBox:~$ sh -ci "$(curl -fsSL https://sdk.dfinity.org/install.sh)"
info: Executing DFINITY SDK install script, commit: dd2134837704e0daca074dd3fe09ee4ff6ebbf97
DFINITY SDK
Please READ the following license:
DFINITY Foundation -- All rights reserved. This is an ALPHA version
of the DFINITY Canister Software Development Kit (SDK). Permission is hereby granted
to use AS IS and only subject to the Alpha DFINITY Canister SDK License Agreement which
can be found here [https://sdk.dfinity.org/sdk-license-agreement.txt]. It comes with NO WARRANTY.
Do you agree and wish to install the DFINITY ALPHA SDK [y/N]?
y
info: Version found: 0.6.10
info: Creating uninstall script in ~/.cache/dfinity
info: uninstall path=/home/adel/.cache/dfinity/uninstall.sh
info: Checking for latest release...
Will install in: /home/adel/bin
info: Installed /home/adel/bin/dfx
adel@adel-VirtualBox:~$ dfx --version
Command 'dfx' not found, did you mean:
command 'fx' from snap fx (11.1.0)
command 'dfix' from snap dfix (0.3.5)
command 'dx' from deb dx (1:4.4.4-12build2)
command 'dex' from deb dex (0.8.0-2)
command 'dfc' from deb dfc (3.1.1-1)
command 'df' from deb coreutils (8.30-3ubuntu2)
See 'snap info <snapname>' for additional versions.
adel@adel-VirtualBox:~$ cd /bin
adel@adel-VirtualBox:/bin$ cd dfx
bash: cd: dfx: No such file or directory
下面是我的 Ubuntu 版本:
adel@adel-VirtualBox:~$ lsb_release -a
No LSB modules are available.
Distributor ID: Ubuntu
Description: Ubuntu 20.04.1 LTS
Release: 20.04
Codename: focal
从安装命令的输出来看,dfx 似乎安装在/home/adel/bin/dfx
中。 您能否验证:
- DFX真的在那里吗?
test -e /home/adel/bin/dfx && echo yay found it || echo oh no
如果没有,则看起来安装不起作用。
如果是,您可以直接运行它:
"$HOME/bin/dfx" --version
- 检查您的路径是否包含"/home/adel/bin">
echo "$PATH" | tr : "n" | grep "$HOME/bin"
如果没有,您可以添加它:
echo 'export PATH="$PATH:$HOME/bin"' >> "$HOME/.bashrc"
. "$HOME/.bashrc"
dfx --version
当我使用命令时
dfx --version
它没有认出。
但是当我使用完整的路径时,它起作用了。
sudo /home/osboxes/bin/dfx --version
DFX 0.8.0
我遇到了同样的问题。出于某种原因,有一个~/bin
目录,所以首先我删除它,然后按照之前的答案进行操作:
ubuntu@ip-172-31-81-158:~$ PATH=~/bin:$PATH
ubuntu@ip-172-31-81-158:~$ export PATH
ubuntu@ip-172-31-81-158:~$ sh -ci "$(curl -fsSL https://sdk.dfinity.org/install.sh)"
info: Executing dfx install script, commit: 0a3bd5b38e498f899c8074d734116c10e0e53ca5
info: Version found: 0.8.3
info: Creating uninstall script in ~/.cache/dfinity
info: uninstall path=/home/ubuntu/.cache/dfinity/uninstall.sh
info: Checking for latest release...
Will install in: /home/ubuntu/bin
info: Installed /home/ubuntu/bin/dfx
ubuntu@ip-172-31-81-158:~$ dfx --version
dfx 0.8.3
你需要给它路径。 运行下面的代码,并确保将二进制文件放在 ~/bin 而不是 ~/bin/dfx 中
export PATH=$PATH:<REPLACE WITH YOUR INSTALLATION PATH>
安装DFX 时,您的安装路径位于底部 在哪里找到环形安装路径
安装DFX 后,在此行添加安装路径 $ 导出路径=$PATH:
通过运行以下命令检查它是否已添加: echo "${PATH//:/$''}">
最后,再次重新启动 Ubuntu 并运行 dfx --version 它肯定会工作并向您展示当前的 dfx 版本 0.11.0
即使在下面提到的导出路径后,我也遇到了以下问题。
export PATH=$PATH:/home/*****/bin/dfx
面临同样的问题:
dfx --version
Command 'dfx' not found, did you mean:
command 'fx' from snap fx (24.1.0)
command 'dfix' from snap dfix (0.3.5)
command 'dex' from deb dex (0.9.0-1)
command 'dx' from deb dx (1:4.4.4-15)
command 'dfc' from deb dfc (3.1.1-1)
command 'df' from deb coreutils (8.32-4.1ubuntu1)
See 'snap info <snapname>' for additional versions
溶液
如上所述,在提及路径后运行命令:
sudo /home/osboxes/bin/dfx --version
要查找路径,请运行以下命令
echo "${PATH//:/$'n'}"
要解决所有问题:我强烈建议遵循投票最多的代码行。
因为对我来说dfx new my_app
不起作用,但在我运行代码行后它起作用了。
test -e /home/navalega0109/bin/dfx && echo yay found it || echo oh no
"$HOME/bin/dfx" --version
echo "$PATH" | tr : "n" | grep "$HOME/bin"
安装到我的本地后,我收到以下消息:
dfx-0.14.3-x86_64-linux.tar.gz: OK
Will install in: /home/akhisyabab/bin
info: Installed /home/akhisyabab/bin/dfx
在 IC 的官方文档中,dfx 应该位于/usr/local/bin/dfx,所以我只是链接位置
sudo ln -s /home/akhisyabab/bin/dfx /usr/local/bin/dfx
它对我有用。谢谢
一旦你重新启动 Ubuntu,它就会工作