Skip to content

Instantly share code, notes, and snippets.

@Neradoc
Last active June 14, 2023 23:05
Show Gist options
  • Save Neradoc/25b768509033c304ff47f1f0ce205a74 to your computer and use it in GitHub Desktop.
Save Neradoc/25b768509033c304ff47f1f0ce205a74 to your computer and use it in GitHub Desktop.
Finder bug when openning files with multiple boards connected

First, random bits from discord conversation:

has anyone encountered a situation on macOS (Catalina) where you double click "code.py" on one circuit python drive but it opens the code.py from another ? I often have multiple devices connected, usually with different drive names (CLUE, QTPY, etc). It happens with different apps, or using the open command line, but it does not happen when using the "open" dialog from within the apps.

let's say I have "BLUEREMOTE" (a feather nrf52) and "CIRCUITBLUE" (a CPB), typing open /Volumes/CIRCUITBLUE/code.py actually opens /Volumes/BLUEREMOTE/code.py

@Neradoc Yes. Lately in Finder, only one CIRCUITPY drive out of many shows up. And so it only opens the files from that drive if I'm opening through finder. I've had to go through command line to find them, or go into /Volumes in Finder. It was not always like that. Something changed.

I use BBEdit, and opening with bbedit /Volumes/CIRCUITBLUE/code.py works as expected but Sublime Text does the same if I switch the default or use open -a open -a "/Applications/Sublime Text.app" /Volumes/CIRCUITBLUE/code.py and so does TextEdit with the boot_out.txt

I don't remember seeing that before... I don't know super recently

I use PyCharm, and haven't tried opening directly into PyCharm from command line. But anything through Finder seems dubious at best.

Unless I happened to have opened the first CIRCUITPY and had it open already, and then it mounts the second one, and that's the one that shows up as mounted, but I can still access the first one.

  • Had the problem happen on Big Sur (tested using boot_out.txt from the Finder).
  • It seems it opens the file from the most recently connected board.
  • My boards are renamed, Volumes/CPCLUE Volumes/QTPYHX Volumes/BLUEREMOTE they don't share the same drive name.
  • Using a simple test app I can confirm there's nothing the app can do about it, it just receives the wrong path when dragging to the app's icon or opening from the finder.
  • Drag-and-dropping the files onto an app that accepts drops (Sublime Text will open the dropped file) does NOT cause the problem (my test app shows we get the right file info).
  • Using BBEdit's service "open with BBEdit" from the right-click menu opens the right file (so menu services have access to the real file ?).
  • Using an Automator service (copy file paths) with the following Applescript in it works correctly (right paths).
on run {input, parameters}
	set liste to {}
	repeat with ffile in input
		set liste to liste & (POSIX path of ffile)
	end repeat
	
	set saveTID to text item delimiters
	set text item delimiters to "
"
	set Final to liste as text
	set text item delimiters to saveTID
	
	return Final
end run
  • Running the following script reproduces the error (it's the Finder again)
on run {input, parameters}
	set liste to {}
	repeat with ffile in input
		tell application "Finder" to open file ffile
	end repeat
end run
  • All of this points at a Finder bug I guess

  • Even weirder, opening a file causes a reload on the board that contains the file (which is usual on mac, I guess it "touches" the file or the drive on open) but opens the file from another board (the other board does not reload).

  • Quickloock does NOT have the bug. Pressing space in the Finder to see the content of a file displays the correct file.

  • I need to do some tests with CIRCUITPY boards and the Finder.

@Neradoc
Copy link
Author

Neradoc commented Jun 14, 2023

Note: this seems fixed by adafruit/circuitpython#7410
(You have to format the drive)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment