carlobaldassi / ArgParse.jl

Package for parsing command-line arguments to Julia programs.
Other
236 stars 36 forks source link

Parsing failure with as_symbols=true and commands_are_required=false #100

Closed alhirzel closed 3 years ago

alhirzel commented 4 years ago

Encountered what appears to be a corner case with symbols and commands.

using ArgParse, Test

s = ArgParseSettings()
s.commands_are_required = false

@add_arg_table! s begin
    "foobar"
        action = :command
end

@test isnothing(parse_args([], s)["%COMMAND%"])
@test isnothing(parse_args([], s; as_symbols=true)[:_COMMAND_])
Error During Test at /tmp/interesting.jl:12
  Test threw exception
  Expression: isnothing((parse_args([], s; as_symbols = true))[:_COMMAND_])
  KeyError: key nothing not found
  Stacktrace:
   [1] getindex(::Dict{String,Any}, ::Nothing) at ./dict.jl:467
   [2] convert_to_symbols(::Dict{String,Any}) at /home/alhirzel/.julia/packages/ArgParse/WUIf8/src/parsing.jl:934
   [3] parse_args(::Array{T,1} where T, ::ArgParseSettings; as_symbols::Bool) at /home/alhirzel/.julia/packages/ArgParse/WUIf8/src/parsing.jl:474
   [4] top-level scope at /tmp/interesting.jl:12
   [5] include(::Function, ::Module, ::String) at ./Base.jl:380
   [6] include(::Module, ::String) at ./Base.jl:368
   [7] exec_options(::Base.JLOptions) at ./client.jl:296
   [8] _start() at ./client.jl:506

ERROR: LoadError: There was an error during testing
in expression starting at /tmp/interesting.jl:12

https://github.com/carlobaldassi/ArgParse.jl/blob/92764f24e1149a8b81860667f0f7d74d0af5a99a/src/parsing.jl#L934

RoyiAvital commented 3 years ago

I also gets this error on Windows:

image

using ArgParse
[ Info: Precompiling ArgParse [c7e460c6-2fb9-53a9-8c5b-16f535851c63]
ERROR: IOError: unlink: permission denied (EACCES)
Stacktrace:
 [1] uv_error at .\libuv.jl:97 [inlined]
 [2] unlink(::String) at .\file.jl:918
 [3] rm(::String; force::Bool, recursive::Bool) at .\file.jl:268
 [4] compilecache(::Base.PkgId, ::String) at .\loading.jl:1300
 [5] _require(::Base.PkgId) at .\loading.jl:1030
 [6] require(::Base.PkgId) at .\loading.jl:928
 [7] require(::Module, ::Symbol) at .\loading.jl:923
caused by [exception 1]
IOError: unlink: permission denied (EACCES)
Stacktrace:
 [1] uv_error at .\libuv.jl:97 [inlined]
 [2] unlink(::String) at .\file.jl:918
 [3] rm(::String; force::Bool, recursive::Bool) at .\file.jl:268
 [4] rename(::String, ::String; force::Bool) at .\file.jl:928
 [5] compilecache(::Base.PkgId, ::String) at .\loading.jl:1296
 [6] _require(::Base.PkgId) at .\loading.jl:1030
 [7] require(::Base.PkgId) at .\loading.jl:928
 [8] require(::Module, ::Symbol) at .\loading.jl:923

Any idea?

RoyiAvital commented 3 years ago

@carlobaldassi, Will it solve the issue I raised?

carlobaldassi commented 3 years ago

@RoyiAvital no, your issue seems to be unrelated. It looks like you are getting a complaint about the permissions fr deleting files. It looks like an issue with the julia installation or the packages directory.