GodotEnv icon indicating copy to clipboard operation
GodotEnv copied to clipboard

Failed to copy addon

Open RoboSkyrat opened this issue 1 year ago • 2 comments
trafficstars

When running godotenv addons install in a brand new chickengame project with the following addons.jsonc I receive a failed to copy exception.

Repo steps

run dotnet new chickengame --name "ReproTest" & cd into it

run godotenv addons init

Modify addons.jsonc to be

// Godot addons configuration file for use with the GodotEnv tool.
// See https://github.com/chickensoft-games/GodotEnv for more info.
// -------------------------------------------------------------------- //
// Note: this is a JSONC file, so you can use comments!
// If using Rider, see https://youtrack.jetbrains.com/issue/RIDER-41716
// for any issues with JSONC.
// -------------------------------------------------------------------- //
{
  "$schema": "https://chickensoft.games/schemas/addons.schema.json",
  // "path": "addons", // default
  // "cache": ".addons", // default
  "addons": {
    "steam-mutliplayer-peer": {
      "url": "https://github.com/expressobits/steam-multiplayer-peer",
      "checkout": "addon",
      "subfolder": "addons/steam-mutliplayer-peer"
    }
  }
}

run godotenv addons install

Result

Discovered "steam-mutliplayer-peer."

  Resolved: Addon "steam-mutliplayer-peer" from `addons.jsonc` at `addons/steam-mutliplayer-peer/` on branch `addon` of `https://github.com/expressobits/steam-multiplayer-peer`

An error was encountered while attempting to install addons.

System.IO.IOException: Failed to copy `S:\projects\ReproTest\.addons\steam-mutliplayer-peer\addons/steam-mutliplayer-peer\` to `S:\projects\ReproTest\addons\steam-mutliplayer-peer\`
   at Chickensoft.GodotEnv.Common.Clients.FileClient.CopyBulk(IShell shell, String source, String destination) in /home/runner/work/GodotEnv/GodotEnv/GodotEnv/src/common/clients/FileClient.cs:line 496
   at Chickensoft.GodotEnv.Features.Addons.Domain.AddonsRepository.InstallAddonFromCache(IAddon addon, String cacheName) in /home/runner/work/GodotEnv/GodotEnv/GodotEnv/src/features/addons/domain/AddonsRepository.cs:line 215
   at Chickensoft.GodotEnv.Features.Addons.Commands.AddonsLogic.State.Unresolved.On(Install input) in /home/runner/work/GodotEnv/GodotEnv/GodotEnv/src/features/addons/commands/install/AddonsLogic.cs:line 141      
   at Chickensoft.LogicBlocks.LogicBlockAsync`1.RunSafe(Func`1 handler, TState fallback)

An error occurred while installing addons:
Failed to copy `S:\projects\ReproTest\.addons\steam-mutliplayer-peer\addons/steam-mutliplayer-peer\` to `S:\projects\ReproTest\addons\steam-mutliplayer-peer\`

Could not resolve addons. Please address any errors and try again.

Manually copying the addons/steam-multiplayer-peer directory into addons from .addons works just fine, godotenv is just unable to do it by itself. All other addons work fine including gdsteam (another gdextension)

RoboSkyrat avatar Jul 28 '24 23:07 RoboSkyrat

@RoboSkyrat it seems you might be on Windows — can you try installing it from an elevated terminal and see if it still fails? Some files or file types might have permissions errors.

jolexxa avatar Jul 29 '24 14:07 jolexxa

I just tried it again, I receive the same error within an administrator terminal. Digging into the source and running robocopy myself it runs just fine and returns the correct exit code ( 1 or 0 depending on I've run it previously)

RoboSkyrat avatar Jul 29 '24 21:07 RoboSkyrat

I have figured it out, after taking a step back and looking over my addons.jsonc file I realized that I had set subfolder incorrectly. My bad.

RoboSkyrat avatar Aug 12 '24 23:08 RoboSkyrat

@RoboSkyrat okay, glad you figured it out and glad it's nothing wrong! 🤠

jolexxa avatar Aug 13 '24 15:08 jolexxa

@RoboSkyrat Could you elaborate what you mean by "set the subfolder incorrectly"? I'm getting the same error on Windows 11 when testing out a specific repo, weirdly enough the default package works but not the one I added myself into the addons file. Here's what it looks like:

{
  "$schema": "https://chickensoft.games/schemas/addons.schema.json",
  // "path": "addons", // default
  // "cache": ".addons", // default
  "addons": {
    "imrp": { // name must match the folder name in the repository
      "url": "https://github.com/MakovWait/improved_resource_picker",
      // "source": "remote", // default
      // "checkout": "main", // default
      "subfolder": "addons/imrp"
    },
    "godot-realistic-water": { // name must match the folder name in the repository
      "url": "https://github.com/godot-extended-libraries/godot-realistic-water",
      // "source": "remote", // default
      "checkout": "v1.0", // default
      "subfolder": "addons/godot-realistic-water"
    }
  }
}

Looking at the error message I noticed it said Failed to copy from "...ProjectName\.addons/godot-realistic-water" i.e. it used forward slash when the rest of the path used backslash. I thought that might be the issue so I tried "subfolder": "addons\\godot-realistic-water" but that still resulted in the same error. I also tried with an elevated terminal, no luck there either.

I'm not sure what else the subfolder value has to be set to to correct this, shouldn't it just be addons/folder-name? Also if this is a common occurrence on Windows, it would be helpful to print a more useful message in the console or put something in the README to clarify what has to be changed! Thanks for the help :)

RobProductions avatar Dec 09 '24 17:12 RobProductions

@RobProductions the subfolder value is supposed to point to where in the addon repo the addon files are located. In your case godot-realistic-water doesn't follow the addons/addonName folder structure of most addons so that isn't going to work. I am unsure which files are important but you could try just using realistic_water_shader for subfolder and give that a whirl.

RoboSkyrat avatar Dec 09 '24 18:12 RoboSkyrat

@RoboSkyrat That was it, thank you so much! I commented out subfolder to leave it as the default "/" value including everything and it worked! Now I feel stupid 😢 But I figured it would be something simple like that...

Really though, I think this highlights a clarity issue with the README. To be fair, it says:

By default, GodotEnv assumes the addon source is remote, the checkout reference is main, and the subfolder to install is the root / of the repository.

And this is the only note about what "subfolder" means, easy to confuse it to mean "subfolder is the root of your project repository" as opposed to the addon's repository. I believe this should be changed and that more detailed comments can be written in an example .jsonc file in the README, something like:

"godot_dialogue_manager": {
      "url": "https://github.com/nathanhoad/godot_dialogue_manager.git", //The source destination used to retrieve the addon
      "source": "remote",  //The source type to use, can be remote, local, or symlink, etc.
      "checkout": "main", //The branch to use when retrieving the remote package
      "subfolder": "addons/dialogue_manager" //The subfolder location within the addon's repository used to copy files to your addons/ folder
    }

Or just a pure list could be nice, anything that explains it better. Additionally, I believe we could catch this exception here using System.IOException or do a folder existence check and print out something more useful like "Addon repository (addon link) did not contain subfolder value (subfolder value) given in .jsonc file" to be more clear about what went wrong. I know it sounds like overkill but if any of these things had been present I'm pretty sure I could've come to this realization faster, might make a world of difference for people using it in the future! I can maybe look into these as PRs if that sounds good :)

RobProductions avatar Dec 09 '24 18:12 RobProductions

@RobProductions documentation improvement PR's are always welcome!

jolexxa avatar Dec 10 '24 16:12 jolexxa