gpt4 book ai didi

macos - dart2js不会抛出此类文件或目录错误

转载 作者:行者123 更新时间:2023-12-03 04:07:29 25 4
gpt4 key购买 nike

很简单,我在/ usr / local / bin /中有一个指向dart2js的链接,运行时会抛出重复的错误。

我跑了

sudo ln -s /Users/macbook/Development/dart/dart-sdk/bin/dart2js /usr/local/bin/dart2js

从终端运行dart2js时,我看到
...
/usr/local/bin/dart2js: line 9: 1=/Users/macbook/Development/dart/dart-sdk/bin/dart2js: No such file or directory
/usr/local/bin/dart2js: line 9: 1=/Users/macbook/Development/dart/dart-sdk/bin/dart2js: No such file or directory
/usr/local/bin/dart2js: line 9: 1=/Users/macbook/Development/dart/dart-sdk/bin/dart2js: No such file or directory
/usr/local/bin/dart2js: line 9: 1=/Users/macbook/Development/dart/dart-sdk/bin/dart2js: No such file or directory
/usr/local/bin/dart2js: line 9: 1=/Users/macbook/Development/dart/dart-sdk/bin/dart2js: No such file or directory
... etc

我想我只是错误地使用了链接,但是我对知识的了解不足。

最佳答案

我前一段时间遇到这个问题,并发布了此问题Can't run dart command line script using a symlink

我还添加了一种变通办法,它也可能对您的情况有所帮助-您可能需要对其稍加调整,但它应该可以帮助您入门。

A workaround I use now is to create a bash script named 'testscript' in the same directory as testscript.dart and link to this script instead

I lookup the current directory of the bash script and start the dart script (Getting the source directory of a Bash script from within).


#!/bin/bash
ME="$(basename "$(test -L "$0" && readlink "$0" || echo "$0")")"

SOURCE="${BASH_SOURCE[0]}"
while [ -h "$SOURCE" ]; do # resolve $SOURCE until the file is no longer a symlink
DIR="$( cd -P "$( dirname "$SOURCE" )" && pwd )"
SOURCE="$(readlink "$SOURCE")"
[[ $SOURCE != /* ]] && SOURCE="$DIR/$SOURCE" # if $SOURCE was a relative symlink, we need to resolve it relative to the path where the symlink file was located
done
DIR="$( cd -P "$( dirname "$SOURCE" )" && pwd )"

${DIR}/${ME}.dart ${BASH_SOURCE[0]}

Instead of getting the command's (symlinks) name with io.Platform.script I have to pass it as an argument to have it available inside the dart script (I use the name of the symlink used to start the script like an argument inside the dart script) This way I have to distinguish if the script was started directly and use io.Platform.script and args[0] otherwise.

I think this should all be easier.

关于macos - dart2js不会抛出此类文件或目录错误,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/21682200/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com