Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[Bug] Tests fail due to permission error on Windows when running from released package #990

Open
suvayu opened this issue Jan 8, 2025 · 1 comment

Comments

@suvayu
Copy link
Member

suvayu commented Jan 8, 2025

Description

If you follow the instructions from the https://tulipaenergy.github.io/TulipaEnergyModel.jl/dev/10-how-to-use/#(Optional)-Running-automatic-tests, the tests fail on Windows when the user does not have local admin privileges.

PS C:\Users\nadmin> echo $env:TMP
C:\Users\nadmin\AppData\Local\Temp
julia> tempdir()
"C:\\Users\\nadmin\\AppData\\Local\\Temp"

I think since there's no local checkout of the source, Julia creates a "project" directory inside TMP and runs the tests there. This is the relevant part of the code:

@testset "is_seasonal asset without entry in partitions file should use :uniform,1" begin
# Copy Norse and delete a row of the partitions file
dir = mktempdir()
for (root, _, files) in walkdir(joinpath(INPUT_FOLDER, "Norse"))
for file in files
cp(joinpath(root, file), joinpath(dir, file))
end
end
filename = joinpath(dir, "assets-timeframe-partitions.csv")
lines = readlines(filename)
open(filename, "w") do io
for line in lines[1:end-1]
println(io, line)
end
end

Maybe copy creates the files with permissions that are not readable by the user? Can it fail silently? These are the two circumstances I could think of.

Package Version

0.10.2

Julia Version

1.11

Reproduction steps

  1. Login to a Windows user account that does not have admin privileges.
  2. Create a new directory and change into it:
    PS > mkdir mytest
    PS > cd mytest
    
  3. Start Julia, add Tulipa, and run the tests:
    PS > julia --project=.
    julia> ]
    pkg> add TulipaEnergyModel
    pkg> test TulipaEnergyModel
    

Relevant log output

is_seasonal asset without entry in partitions file should use :uniform,1: Error During Test at C:\Users\nadmin\.julia\packages\TulipaEnergyModel\EgSyT\test\test-io.jl:122
  Got exception outside of a @test
  SystemError: opening file "C:\\Users\\nadmin\\AppData\\Local\\Temp\\jl_ECJTdG\\assets-timeframe-partitions.csv": Permission denied
  Stacktrace:
    [1] systemerror(p::String, errno::Int32; extrainfo::Nothing)
      @ Base .\error.jl:176
    [2] systemerror
      @ .\error.jl:175 [inlined]
    [3] open(fname::String; lock::Bool, read::Nothing, write::Nothing, create::Nothing, truncate::Bool, append::Nothing)
      @ Base .\iostream.jl:295
    [4] open
      @ .\iostream.jl:277 [inlined]
    [5] open(fname::String, mode::String; lock::Bool)
      @ Base .\iostream.jl:358
    [6] open(fname::String, mode::String)
      @ Base .\iostream.jl:357
    [7] open(::var"#17#19"{Vector{String}}, ::String, ::Vararg{String}; kwargs::@Kwargs{})
      @ Base .\io.jl:408
    [8] open(::Function, ::String, ::String)
      @ Base .\io.jl:407
    [9] macro expansion
      @ C:\Users\nadmin\.julia\packages\TulipaEnergyModel\EgSyT\test\test-io.jl:132 [inlined]
   [10] macro expansion
      @ C:\Users\nadmin\.julia\juliaup\julia-1.11.2+0.x64.w64.mingw32\share\julia\stdlib\v1.11\Test\src\Test.jl:1704 [inlined]
   [11] top-level scope
      @ C:\Users\nadmin\.julia\packages\TulipaEnergyModel\EgSyT\test\test-io.jl:124
   [12] include
      @ .\sysimg.jl:38 [inlined]
   [13] macro expansion
      @ C:\Users\nadmin\.julia\packages\TulipaEnergyModel\EgSyT\test\runtests.jl:38 [inlined]
   [14] macro expansion
      @ C:\Users\nadmin\.julia\juliaup\julia-1.11.2+0.x64.w64.mingw32\share\julia\stdlib\v1.11\Test\src\Test.jl:1704 [inlined]
   [15] top-level scope
      @ C:\Users\nadmin\.julia\packages\TulipaEnergyModel\EgSyT\test\runtests.jl:38
   [16] include(fname::String)
      @ Main .\sysimg.jl:38
   [17] top-level scope
      @ none:6
   [18] eval
      @ .\boot.jl:430 [inlined]
   [19] exec_options(opts::Base.JLOptions)
      @ Base .\client.jl:296
   [20] _start()
      @ Base .\client.jl:531

Operating System

Windows

@clizbe
Copy link
Member

clizbe commented Jan 10, 2025

Wow really glad you caught this before we start the TLC.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants