fonsp / Pluto.jl

🎈 Simple reactive notebooks for Julia
https://plutojl.org/
MIT License
5k stars 296 forks source link

Pkg error: no method matching project_rel_path #1484

Closed vlc1 closed 3 years ago

vlc1 commented 3 years ago

Hi there,

I'm getting the following error while trying to export a Pluto notebook to html from a Github action using the export_directory function of PlutoSliderServer.jl :

Error: Pkg error: you might need to use

Pluto.reset_notebook_environment(notebook_path)

to reset this notebook's environment.

Before doing so, consider sending your notebook file to https://github.com/fonsp/Pluto.jl/issues together with the following info:

  Pluto.PLUTO_VERSION = v"0.16.1"
  VERSION = v"1.6.2"
  exception = 
    MethodError: no method matching project_rel_path(::Pkg.Types.Context, ::Nothing)
    Closest candidates are:
      project_rel_path(::Pkg.Types.Context, !Matched::String) at /buildworker/worker/package_linux64/build/usr/share/julia/stdlib/v1.6/Pkg/src/Operations.jl:847
    Stacktrace:
      [1] package_info(ctx::Pkg.Types.Context, pkg::Pkg.Types.PackageSpec, entry::Pkg.Types.PackageEntry)
        @ Pkg.Operations /buildworker/worker/package_linux64/build/usr/share/julia/stdlib/v1.6/Pkg/src/Operations.jl:1714
      [2] package_info
        @ /buildworker/worker/package_linux64/build/usr/share/julia/stdlib/v1.6/Pkg/src/Operations.jl:1707 [inlined]
      [3] #10
        @ ./none:0 [inlined]
      [4] iterate
        @ ./generator.jl:47 [inlined]
      [5] _all(f::Base.var"#282#284", itr::Base.Generator{Vector{Pkg.Types.PackageSpec}, Pkg.API.var"#10#11"{Pkg.Types.Context}}, #unused#::Colon)
        @ Base ./reduce.jl:930
      [6] all
        @ ./reduce.jl:918 [inlined]
      [7] Dict(kv::Base.Generator{Vector{Pkg.Types.PackageSpec}, Pkg.API.var"#10#11"{Pkg.Types.Context}})
        @ Base ./dict.jl:131
      [8] dependencies
        @ /buildworker/worker/package_linux64/build/usr/share/julia/stdlib/v1.6/Pkg/src/API.jl:28 [inlined]
      [9] dependencies(ctx::Pkg.Types.Context)
        @ Pluto.PkgCompat ~/.julia/packages/Pluto/nkHsc/src/packages/PkgCompat.jl:321
     [10] _get_manifest_entry
        @ ~/.julia/packages/Pluto/nkHsc/src/packages/PkgCompat.jl:353 [inlined]
     [11] get_manifest_version(ctx::Pkg.Types.Context, package_name::String)
        @ Pluto.PkgCompat ~/.julia/packages/Pluto/nkHsc/src/packages/PkgCompat.jl:364
     [12] (::Pluto.var"#144#145"{Pkg.Types.Context})(x::String)
        @ Pluto ./none:0
     [13] iterate
        @ ./generator.jl:47 [inlined]
     [14] Dict{String, String}(kv::Base.Generator{Base.KeySet{String, Dict{String, Base.UUID}}, Pluto.var"#144#145"{Pkg.Types.Context}})
        @ Base ./dict.jl:103
     [15] nbpkg_cache
        @ ~/.julia/packages/Pluto/nkHsc/src/packages/Packages.jl:445 [inlined]
     [16] load_notebook_nobackup(io::IOStream, path::String)
        @ Pluto ~/.julia/packages/Pluto/nkHsc/src/notebook/Notebook.jl:277
     [17] #52
        @ ~/.julia/packages/Pluto/nkHsc/src/notebook/Notebook.jl:283 [inlined]
     [18] open(::Pluto.var"#52#53"{String}, ::String, ::Vararg{String, N} where N; kwargs::Base.Iterators.Pairs{Union{}, Union{}, Tuple{}, NamedTuple{(), Tuple{}}})
        @ Base ./io.jl:330
     [19] open
        @ ./io.jl:328 [inlined]
     [20] load_notebook_nobackup(path::String)
        @ Pluto ~/.julia/packages/Pluto/nkHsc/src/notebook/Notebook.jl:282
     [21] load_notebook(path::String; disable_writing_notebook_files::Bool)
        @ Pluto ~/.julia/packages/Pluto/nkHsc/src/notebook/Notebook.jl:299
     [22] open(session::Pluto.ServerSession, path::String; run_async::Bool, compiler_options::Nothing, as_sample::Bool)
        @ Pluto.SessionActions ~/.julia/packages/Pluto/nkHsc/src/webserver/SessionActions.jl:37
     [23] add_to_session!(notebook_sessions::Vector{PlutoSliderServer.../Types.jl.Types.NotebookSession}, server_session::Pluto.ServerSession, path::String, settings::PlutoSliderServer.../Types.jl.Types.PlutoDeploySettings, run_server::Bool, start_dir::String)
        @ PlutoSliderServer.../Actions.jl.Actions ~/.julia/packages/PlutoSliderServer/A6UIQ/src/Actions.jl:33
     [24] run_directory(start_dir::String; notebook_paths::Vector{String}, static_export::Bool, run_server::Bool, on_ready::PlutoSliderServer.var"#48#57", config_toml_path::String, kwargs::Base.Iterators.Pairs{Symbol, String, Tuple{Symbol}, NamedTuple{(:Export_output_dir,), Tuple{String}}})
        @ PlutoSliderServer ~/.julia/packages/PlutoSliderServer/A6UIQ/src/PlutoSliderServer.jl:207
     [25] #export_directory#36
        @ ~/.julia/packages/PlutoSliderServer/A6UIQ/src/PlutoSliderServer.jl:70 [inlined]
     [26] top-level scope
        @ none:5
     [27] eval
        @ ./boot.jl:360 [inlined]
     [28] exec_options(opts::Base.JLOptions)
        @ Base ./client.jl:261
     [29] _start()
        @ Base ./client.jl:485

The notebook is available in this repository and the full log of the action here.

Any help will be much appreciated! Thanks!

Vincent

fonsp commented 3 years ago

You can probably ignore the error, your github action failed because the build folder already exists. Can you fix this and let me know if the github action worked?

vlc1 commented 3 years ago

Dear @fonsp,

Thanks for your prompt response. That was a separate issue I believe, I'm getting a similar error after fixing that.

I'm doing something wrong in my Github Action workflow I think, I'll have a look at what you did with the one you used for the Computational Thinking class (https://github.com/mitmath/18S191/blob/Spring21/.github/workflows/ExportNotebooks.yml).

I'll keep you posted. Thanks!

vlc1 commented 3 years ago

I realized there is a specific function in PlutoSliderServer.jl (github_action), but I still have the following error :

Error: Could not parse entry for `deps`
Error: Failed to load notebook files: Project.toml+Manifest.toml parse error. Trying to recover Project.toml without Manifest.toml...

as can be seen here...

fonsp commented 3 years ago

Use this one: https://github.com/JuliaPluto/static-export-template

vlc1 commented 3 years ago

I think the problem was coming from the directory I was storing the notebook. After removing it, it worked as seen here.

Do you think there is an easy way to fix this?

Thanks a lot @fonsp!

fonsp commented 3 years ago

What do you mean? Fix what?

vlc1 commented 3 years ago

Hi @fonsp,

The repository had the following structure :

.github/workflows/deploy.yml
notebooks/cauchy.jl

and by changing it to

.github/workflows/deploy.yml
cauchy.jl

it fixed the issue. Please let me know if this explains better. Thanks!

fonsp commented 3 years ago

Can you use the https://github.com/JuliaPluto/static-export-template and see if this subfolder-problem also exists there? This should definitely be supported, we also have tests for it.

vlc1 commented 3 years ago

I did just that : used the template, moved the notebook included in static-export-template in a subfolder, and it worked. However when replacing the original My Cool Notebook.jl with my own notebook, the same error appeared.

So I think the issue comes from my notebook, I'll fix it thanks @fonsp for the pointers!

vlc1 commented 3 years ago

Ok I finally got it : the Julia version used to create the Pluto notebook didn't match the one from the YAML action file... The error doesn't show anymore, thanks @fonsp for your help!