rojo icon indicating copy to clipboard operation
rojo copied to clipboard

$paths that contain .. cause change detection to break on macOS

Open eAi opened this issue 3 years ago • 1 comments

As we've discussed on Discord, having a $path that contains .. causes the change detection to break. This means that rojo doesn't send changes to the Roblox Studio plugin.

This relates to Rojo 7.0.0.

Here is a sample project.json that is placed in a 'place_config' folder within the root of the project that reproduces this:

{
    "name": "project",
    "tree": {
        "$className": "DataModel",
        "StarterPlayer": {
            "$className": "StarterPlayer",
            "StarterPlayerScripts": {
                "$className": "StarterPlayerScripts",
                "$ignoreUnknownInstances": true,
                "$path": "../src/StarterPlayer/StarterPlayerScripts"
            }
        }
    }
}

Here is the verbose log:

eai@MBP-2 Frontend % rojo serve place_configs/test.project.json -vvvv
[TRACE librojo::serve_session] Starting new ServeSession at path /Users/eai/Code/work/project/Frontend/place_configs/test.project.json
[DEBUG librojo::serve_session] Loading project file from /Users/eai/Code/work/project/Frontend/place_configs/test.project.json
[TRACE librojo::serve_session] Generating snapshot of instances from VFS
[TRACE librojo::serve_session] Computing initial patch set
[TRACE librojo::serve_session] Applying initial patch set
[TRACE librojo::serve_session] Starting ChangeProcessor
[TRACE librojo::change_processor] ChangeProcessor thread started
Rojo server listening:
  Address: localhost
  Port:    34872

Visit http://localhost:34872/ in your browser for more information.
[TRACE mio::poll] registering event source with poller: token=Token(0), interests=READABLE | WRITABLE
[TRACE mio::poll] registering event source with poller: token=Token(1), interests=READABLE | WRITABLE
[TRACE librojo::change_processor] Vfs event: Write("/Users/eai/Code/work/project/Frontend/src/StarterPlayer/StarterPlayerScripts/Controllers/script.lua")
[TRACE librojo::change_processor] Path /Users/eai/Code/work/project/Frontend/src/StarterPlayer/StarterPlayerScripts/Controllers/script.lua affects IDs []
[TRACE librojo::change_processor] Trying parent path...
[TRACE librojo::change_processor] Path /Users/eai/Code/work/project/Frontend/src/StarterPlayer/StarterPlayerScripts/Controllers affects IDs []
[TRACE librojo::change_processor] Trying parent path...
[TRACE librojo::change_processor] Path /Users/eai/Code/work/project/Frontend/src/StarterPlayer/StarterPlayerScripts affects IDs []
[TRACE librojo::change_processor] Trying parent path...
[TRACE librojo::change_processor] Path /Users/eai/Code/work/project/Frontend/src/StarterPlayer affects IDs []
[TRACE librojo::change_processor] Trying parent path...
[TRACE librojo::change_processor] Path /Users/eai/Code/work/project/Frontend/src affects IDs []
[TRACE librojo::change_processor] Trying parent path...
[TRACE librojo::change_processor] Path /Users/eai/Code/work/project/Frontend affects IDs []
[TRACE librojo::change_processor] Trying parent path...
[TRACE librojo::change_processor] Path /Users/eai/Code/work/project affects IDs []
[TRACE librojo::change_processor] Trying parent path...
[TRACE librojo::change_processor] Path /Users/eai/Code/work affects IDs []
[TRACE librojo::change_processor] Trying parent path...
[TRACE librojo::change_processor] Path /Users/eai/Code affects IDs []
[TRACE librojo::change_processor] Trying parent path...
[TRACE librojo::change_processor] Path /Users/eai affects IDs []
[TRACE librojo::change_processor] Trying parent path...
[TRACE librojo::change_processor] Path /Users affects IDs []
[TRACE librojo::change_processor] Trying parent path...
[TRACE librojo::change_processor] Path / affects IDs []
[TRACE librojo::change_processor] Trying parent path...

If a similar project.json file is placed in the root of the project, this works fine:

{
    "name": "project",
    "tree": {
        "$className": "DataModel",
        "StarterPlayer": {
            "$className": "StarterPlayer",
            "StarterPlayerScripts": {
                "$className": "StarterPlayerScripts",
                "$ignoreUnknownInstances": true,
                "$path": "src/StarterPlayer/StarterPlayerScripts"
            }
        }
    }
}

Log:

eai@MBP-2 Frontend % rojo serve test.project.json -vvvv              
[TRACE librojo::serve_session] Starting new ServeSession at path /Users/eai/Code/work/project/Frontend/test.project.json
[DEBUG librojo::serve_session] Loading project file from /Users/eai/Code/work/project/Frontend/test.project.json
[TRACE librojo::serve_session] Generating snapshot of instances from VFS
[TRACE librojo::serve_session] Computing initial patch set
[TRACE librojo::serve_session] Applying initial patch set
[TRACE librojo::serve_session] Starting ChangeProcessor
[TRACE librojo::change_processor] ChangeProcessor thread started
Rojo server listening:
  Address: localhost
  Port:    34872

Visit http://localhost:34872/ in your browser for more information.
[TRACE mio::poll] registering event source with poller: token=Token(0), interests=READABLE | WRITABLE
[TRACE librojo::change_processor] Vfs event: Write("/Users/eai/Code/work/project/Frontend/src/StarterPlayer/StarterPlayerScripts/Controllers/script.lua")
[TRACE librojo::change_processor] Path /Users/eai/Code/work/project/Frontend/src/StarterPlayer/StarterPlayerScripts/Controllers/script.lua affects IDs [Ref(Some(192997763458208094234213798092352309143))]

eAi avatar Jan 11 '22 10:01 eAi

After we discussed this, it seemed as though the best fix was to use a function similar to this on paths in the project.json. Other solutions discussed (such as finding canonical paths instead) may have interactions with symlinks which may resolve #278 on Windows, but cause similar issues on Mac/Linux.

eAi avatar Jan 11 '22 10:01 eAi