Pkg.jl: ERROR getcwd: no such file or directory (ENOENT)

Created on 14 Aug 2018  Â·  20Comments  Â·  Source: JuliaLang/Pkg.jl

I got this error on 0.7.0 on linux

(v0.7) pkg> add Knet#master
   Cloning git-repo `https://github.com/denizyuret/Knet.jl.git`
  Updating git-repo `https://github.com/denizyuret/Knet.jl.git`
 Resolving package versions...
ERROR: IOError: getcwd: no such file or directory (ENOENT)
Stacktrace:
 [1] uv_error at ./libuv.jl:85 [inlined]
 [2] uv_error at ./libuv.jl:84 [inlined]
 [3] pwd() at ./file.jl:53
 [4] pathrepr at /buildworker/worker/package_linux64/build/usr/share/julia/stdlib/v0.7/Pkg/src/Types.jl:1113 [inlined]
 [5] #write_env#65(::Bool, ::Function, ::Pkg.Types.Context) at /buildworker/worker/package_linux64/build/usr/share/julia/stdlib/v0.7/Pkg/src/Types.jl:1148
 [6] write_env at /buildworker/worker/package_linux64/build/usr/share/julia/stdlib/v0.7/Pkg/src/Types.jl:1140 [inlined]
 [7] #add_or_develop#58(::Array{Base.UUID,1}, ::Function, ::Pkg.Types.Context, ::Array{Pkg.Types.PackageSpec,1}) at /buildworker/worker/package_linux64/build/usr/share/julia/stdlib/v0.7/Pkg/src/Operations.jl:1165
 [8] #add_or_develop at ./none:0 [inlined]
 [9] #add_or_develop#13(::Symbol, ::Bool, ::Base.Iterators.Pairs{Union{},Union{},Tuple{},NamedTuple{(),Tuple{}}}, ::Function, ::Pkg.Types.Context, ::Array{Pkg.Types.PackageSpec,1}) at /buildworker/worker/package_linux64/build/usr/share/julia/stdlib/v0.7/Pkg/src/API.jl:64
 [10] (::getfield(Pkg.API, Symbol("#kw##add_or_develop")))(::NamedTuple{(:mode,),Tuple{Symbol}}, ::typeof(Pkg.API.add_or_develop), ::Pkg.Types.Context, ::Array{Pkg.Types.PackageSpec,1}) at ./none:0
 [11] do_add!(::Dict{Symbol,Any}, ::Array{Pkg.Types.PackageSpec,1}, ::Dict{Symbol,Any}) at /buildworker/worker/package_linux64/build/usr/share/julia/stdlib/v0.7/Pkg/src/REPLMode.jl:633
 [12] #invokelatest#1(::Base.Iterators.Pairs{Union{},Union{},Tuple{},NamedTuple{(),Tuple{}}}, ::Function, ::Any, ::Any, ::Vararg{Any,N} where N) at ./essentials.jl:691
 [13] invokelatest(::Any, ::Any, ::Vararg{Any,N} where N) at ./essentials.jl:690
 [14] do_cmd!(::Pkg.REPLMode.PkgCommand, ::REPL.LineEditREPL) at /buildworker/worker/package_linux64/build/usr/share/julia/stdlib/v0.7/Pkg/src/REPLMode.jl:542
 [15] #do_cmd#30(::Bool, ::Function, ::REPL.LineEditREPL, ::String) at /buildworker/worker/package_linux64/build/usr/share/julia/stdlib/v0.7/Pkg/src/REPLMode.jl:507
 [16] do_cmd at /buildworker/worker/package_linux64/build/usr/share/julia/stdlib/v0.7/Pkg/src/REPLMode.jl:503 [inlined]
 [17] (::getfield(Pkg.REPLMode, Symbol("##41#44")){REPL.LineEditREPL,REPL.LineEdit.Prompt})(::REPL.LineEdit.MIState, ::Base.GenericIOBuffer{Array{UInt8,1}}, ::Bool) at /buildworker/worker/package_linux64/build/usr/share/julia/stdlib/v0.7/Pkg/src/REPLMode.jl:842
 [18] #invokelatest#1 at ./essentials.jl:691 [inlined]
 [19] invokelatest at ./essentials.jl:690 [inlined]
 [20] run_interface(::REPL.Terminals.TextTerminal, ::REPL.LineEdit.ModalInterface, ::REPL.LineEdit.MIState) at /buildworker/worker/package_linux64/build/usr/share/julia/stdlib/v0.7/REPL/src/LineEdit.jl:2261
 [21] run_frontend(::REPL.LineEditREPL, ::REPL.REPLBackendRef) at /buildworker/worker/package_linux64/build/usr/share/julia/stdlib/v0.7/REPL/src/REPL.jl:1029
 [22] run_repl(::REPL.AbstractREPL, ::Any) at /buildworker/worker/package_linux64/build/usr/share/julia/stdlib/v0.7/REPL/src/REPL.jl:191
 [23] (::getfield(Base, Symbol("##831#833")){Bool,Bool,Bool,Bool})(::Module) at ./logging.jl:311
 [24] #invokelatest#1 at ./essentials.jl:691 [inlined]
 [25] invokelatest at ./essentials.jl:690 [inlined]
 [26] macro expansion at ./logging.jl:308 [inlined]
 [27] run_main_repl(::Bool, ::Bool, ::Bool, ::Bool, ::Bool) at ./client.jl:340
 [28] exec_options(::Base.JLOptions) at ./client.jl:252
 [29] _start() at ./client.jl:432

Unfortunately, I could not reproduce it anymore after a pkg> rm Knet and a rm -rf .julia/dev/Knet, so I don't know how to help anyone in reproducing it, I'm sorry

bug

Most helpful comment

All 20 comments

It seems likely that you ended up in a situation where your current working directory no longer exists.

that could indeed be the case, closing for now

No, we should still not fail like this.

I just got this error message, Julia 1.0.1.

Stacktrace?

I have a similar problem with Julia 1.0.2 running on Windows 7

What is the stacktrace?

I have the same kind of message no matter the package I build on Windows 7:

Error building GR:
� N�o� �s�e� �p�u�e�d�e� �i�n�i�c�i�a�r� �l�a� �v�e�r�s�i���n� �3� �d�e� �W�i�n�d�o�w�s� �P�o�w�e�r�S�h�e�l�l�.� �N�o� �e�s�t��� �i�n�s�t�a�l�a�d�a� �c�o�r�r�e�c�t�a�m�e�n�t�e�.�
� �N�o� �s�e� �p�u�e�d�e� �i�n�i�c�i�a�r� �l�a� �v�e�r�s�i���n� �3� �d�e� �W�i�n�d�o�w�s� �P�o�w�e�r�S�h�e�l�l�.� �N�o� �e�s�t��� �i�n�s�t�a�l�a�d�a� �c�o�r�r�e�c�t�a�m�e�n�t�e�.�
│ �[ Info: Downloading pre-compiled GR 0.35.0 Windows binary
│ [ Info: Using insecure connection
│ [ Info: Cannot download GR run-time
│ ERROR: LoadError: IOError: chmod: no such file or directory (ENOENT)
│ Stacktrace:
│ [1] uv_error at .\libuv.jl:85 [inlined]
│ [2] #chmod#16(::Bool, ::Function, ::String, ::UInt16) at .\file.jl:829
│ [3] chmod at .\file.jl:828 [inlined]
│ [4] #rm#9(::Bool, ::Bool, ::Function, ::String) at .\file.jl:250
│ [5] rm(::String) at .\file.jl:245
│ [6] top-level scope at logging.jl:319
│ [7] top-level scope at C:\Users\med.julia\packagesGR\k8wwU\deps\build.jl:91
│ [8] include at .\boot.jl:317 [inlined]
│ [9] include_relative(::Module, ::String) at .\loading.jl:1044
│ [10] include(::Module, ::String) at .\sysimg.jl:29
│ [11] include(::String) at .\client.jl:392
│ [12] top-level scope at none:0
│ in expression starting at C:\Users\med.julia\packagesGR\k8wwU\deps\build.jl:63
â”” @ Pkg.Operations C:\cygwin\home\Administrator\buildbot\worker\package_win64\build\usr\share\julia\stdlib\v1.0\Pkg\src\Operations.jl:1097

On a different computer with Windows 10 everything works fine.

Seeks this is happening from GR.jl (https://github.com/jheinen/GR.jl/blob/a25a7f1b15e8a9b6281ebec10cabbe838536f41d/deps/build.jl#L108). Not sure what we can do about that here.

I solved my problem:
https://discourse.julialang.org/t/error-building-packages-on-windows-7-x64-old-title-gr-jl/17510/13
I tried several things, I think the two that solved the problem were upgrading Powershell to version 3 and enabling TLS 1.2

I just had the same problelm after updating Julia from 1.0.1 to 1.0.2 via brew cask and going for a package update.

  Building IJulia ────→ `~/.julia/packages/IJulia/DL02A/deps/build.log`
ERROR: IOError: getcwd: no such file or directory (ENOENT)
Stacktrace:
 [1] uv_error at ./libuv.jl:85 [inlined]
 [2] uv_error at ./libuv.jl:84 [inlined]
 [3] pwd() at ./file.jl:53
 [4] abspath at ./path.jl:280 [inlined]
 [5] iterate at ./generator.jl:47 [inlined]
 [6] _collect(::Array{String,1}, ::Base.Generator{Array{String,1},typeof(abspath)}, ::Base.EltypeUnknown, ::Base.HasShape{1}) at ./array.jl:632
 [7] collect_similar at ./array.jl:561 [inlined]
 [8] map at ./abstractarray.jl:1987 [inlined]
 [9] load_path_setup_code(::Bool) at ./loading.jl:1085
 [10] #build_versions#47(::Bool, ::Function, ::Pkg.Types.Context, ::Array{Base.UUID,1}) at /Users/osx/buildbot/slave/package_osx64/build/usr/share/julia/stdlib/v1.0/Pkg/src/Operations.jl:1070
...

Edit: Pkg.build() seemed to fix it.

I get the error again and build doesn't fix it

(v1.2) pkg> up
  Updating registry at `~/.julia/registries/General`
  Updating git-repo `https://github.com/JuliaRegistries/General.git`
  Updating git-repo `https://github.com/JuliaIntervals/IntervalRootFinding.jl.git`
 Resolving package versions...
  Updating `~/.julia/environments/v1.2/Project.toml`
ERROR: IOError: getcwd: no such file or directory (ENOENT)
Stacktrace:
 [1] #write_project at ./none:0 [inlined]
 [2] #write_env#147 at /build/julia/src/julia-1.2.0/usr/share/julia/stdlib/v1.2/Pkg/src/Types.jl:1347 [inlined]
 [3] write_env at /build/julia/src/julia-1.2.0/usr/share/julia/stdlib/v1.2/Pkg/src/Types.jl:1345 [inlined]
 [4] up(::Pkg.Types.Context, ::Array{Pkg.Types.PackageSpec,1}, ::Pkg.Types.UpgradeLevel) at /build/julia/src/julia-1.2.0/usr/share/julia/stdlib/v1.2/Pkg/src/Operations.jl:1048
 [5] #up#43(::Pkg.Types.UpgradeLevel, ::Pkg.Types.PackageMode, ::Bool, ::Base.Iterators.Pairs{Union{},Union{},Tuple{},NamedTuple{(),Tuple{}}}, ::typeof(Pkg.API.up), ::Pkg.Types.Context, ::Array{Pkg.Types.PackageSpec,1}) at /build/julia/src/julia-1.2.0/usr/share/julia/stdlib/v1.2/Pkg/src/API.jl:167
 [6] up at /build/julia/src/julia-1.2.0/usr/share/julia/stdlib/v1.2/Pkg/src/API.jl:143 [inlined]
 [7] do_up!(::Dict{Symbol,Any}, ::Array{Pkg.Types.PackageSpec,1}, ::Dict{Symbol,Any}) at /build/julia/src/julia-1.2.0/usr/share/julia/stdlib/v1.2/Pkg/src/REPLMode.jl:483
 [8] invokelatest(::Any, ::Any, ::Vararg{Any,N} where N) at ./essentials.jl:789

Got this error on 1.2. (Use case was Jupyter notebook open in a directory that is populated with make blahblah and cleaned with make clean, and I usually leave it running between build/clean cycles.)

Same here. I updated some packages using up, and today I tried importing some data as usual at first, I keep getting this error

Is the stacktrace the same?

Does the folder where you run commands actually exist?

The big open question here is whether people who are encountering this are running a Julia session in a directory which then gets deleted. If so, there's not much we can do about it: most code expects not to be running in a deleted directory. If that's not the case, then this is quite strange and is indeed a bug. However, that's not entirely clear from these bug reports. So, if someone who finds themselves in this situation could do a more thorough investigation when they find themselves in this situation next, that would be what's necessary to make forward progress on this.

As an example of how this can happen: you're running Julia in one terminal window, meanwhile you delete the directory that it's running in from another terminal window. Even if you recreate a directory by the same name, the Julia session's current working directory will be a deleted, orphaned directory in the filesystem and you'll get this error because the working directory is orphaned. You can even accomplish this from within the same process:

julia> t = mktempdir()
"/var/folders/4g/b8p546px3nd550b3k288mhp80000gp/T/jl_Gby7ta"

julia> cd(t)

julia> pwd()
"/private/var/folders/4g/b8p546px3nd550b3k288mhp80000gp/T/jl_Gby7ta"

julia> rm(t, recursive=true)

julia> pwd()
ERROR: IOError: cwd: no such file or directory (ENOENT)

Even if you recreate the directory after that, the current working directory is an inode, not a path, so you're still in a deleted directory:

julia> mkdir(t)
"/var/folders/4g/b8p546px3nd550b3k288mhp80000gp/T/jl_Gby7ta"

julia> pwd()
ERROR: IOError: cwd: no such file or directory (ENOENT)

That's what has happened for me! I made another directory and clone the repo again and it worked.

If we want to address this, I guess we can try deleting the cwd and then run various Pkg commands and see where being in a deleted fails, but it's a pretty low priority, imo.

Was this page helpful?
0 / 5 - 0 ratings

Related issues

KristofferC picture KristofferC  Â·  4Comments

jebej picture jebej  Â·  3Comments

oxinabox picture oxinabox  Â·  3Comments

timholy picture timholy  Â·  4Comments

KristofferC picture KristofferC  Â·  4Comments