我正在尝试升级Haskell堆栈的副本,如下所示:
public class Test{
private int[] array = new int [5];
public int method(int i) {
for(int s = 0; s <= array.length; s++) {
if( array[s] != null) { //I get the error in here even though the highest upvoted answer in the linked question recommends this solution. I obviously cant check it for 0, because the user input can be 0.
array[s] = i;
} else {
method(i);
}
}
}
}
为什么mac:~ me$ stack --version
Version 1.4.0, Git revision e714f1dd3fade19496d91bd6a017e435a96a6bcd (4640 commits) x86_64 hpack-0.17.0
mac:~ me$ stack upgrade
Current Stack version: 1.4.0, available download version: 1.7.1
Newer version detected, downloading
Querying for archive location for platform: osx-x86_64-static
Querying for archive location for platform: osx-x86_64
Downloading from: https://github.com/commercialhaskell/stack/releases/download/v1.7.1/stack-1.7.1-osx-x86_64.tar.gz
Download complete, testing executable
Version 1.7.1, Git revision 681c800873816c022739ca7ed14755e85a579565 (5807 commits) x86_64 hpack-0.28.2
New stack executable available at /Users/me/.local/bin/stack
mac:~ me$ stack --version
Version 1.4.0, Git revision e714f1dd3fade19496d91bd6a017e435a96a6bcd (4640 commits) x86_64 hpack-0.17.0
mac:~ me$ which stack
/Users/me/.local/bin/stack
似乎正确升级了堆栈,声称安装了新版本,然后甚至说stack upgrade
,但实际上并没有在测试时升级堆栈版本,New stack executable available at /Users/me/.local/bin/stack
命令确认运行的确实是新堆栈可执行文件的位置?
由于Probie的建议,我检查了which
是否报告了更新的版本,并且确实如此:
/Users/me/.local/bin/stack --version
出于这个原因,这使我彻底感到困惑:
mac:~ me$ /Users/me/.local/bin/stack --version
Version 1.7.1, Git revision 681c800873816c022739ca7ed14755e85a579565 (5807 commits) x86_64 hpack-0.28.2
为什么使用mac:~ me$ /Users/me/.local/bin/stack --version
Version 1.7.1, Git revision 681c800873816c022739ca7ed14755e85a579565 (5807 commits) x86_64 hpack-0.28.2
mac:~ me$ which stack
/Users/me/.local/bin/stack
mac:~ me$ stack --version
Version 1.4.0, Git revision e714f1dd3fade19496d91bd6a017e435a96a6bcd (4640 commits) x86_64 hpack-0.17.0
命令运行的堆栈版本与stack
命令显示的位置显示的版本不同?
答案 0 :(得分:2)
编辑:
事实证明,就bash而言,which
并没有返回正确的结果。 It might be related to this
很可能bash缓存了堆栈的位置,并且没有使用新的堆栈。
尝试运行hash stack
,然后重试。 (否则,如果hash -r
无法清空缓存)