First post in the forums! Hope I got it all figured out correctly!
I like to have some of my sketches in a different location from the Sketchbook. This did seem to pose an issue for the Arduino IDE, as it would only show projects in the file explorer if they are in the Sketchbook, from how I understand it. Thus, a bug report.
Running: Arduino IDE 2.0.0-rc3
On: Windows 10 21H2 19044.1526
Steps to reproduce:
Create a symbolic link into the Sketchbook. Done this in my case with Symlink
Open a file in the Arduino IDE from the linked folder
The file is opened in read-only mode.
If anyone has suggestions for how to fix this, feel free! Otherwise maybe a bug report?
I can not reproduce the issue; maybe you have to give some more details.
I created a shortcut (it's the same as a symlink as far as I know) in C:\Users\sterretje\Documents\Arduino pointing to a library example folder in my downloads directory C:\Users\sterretje\Downloads\arduinolibs\Adafruit_NeoPixel-master\Adafruit_NeoPixel-master\examples\RGBWstrandtest.
I opened the example ino via the shortcut using file->open in the IDE, modified it by adding a comment and saved it (file -> save) successfully.
Interesting. I've tried multiple times with different methods now to recreate the link/junction, but they have all resulted in the same issue for me. How did you create the link?
However, with the skill of randomly clicking everywhere, I have discovered the Explorer (right clicking the tab of the open file, reveals the shortcut Alt + R), which I feel wasn't there before. I can work in the folder which I tried to link to ~/Documents/Arduino/Projects/ directly now, saving the need for a Symbolic link.
I'm still interested as to why it does seem to work on your machine, so if you have any details with regards to the commands used for the linking, greatly appreciated! In my case, I used
Right click the directory that contains the ino file, select create shortcut from the context menu.
Move the shortcut to the arduino sketchbook directory.
That ~ as well as the forward slashes would indicate a non-windows OS. What did you forget to mention?
Apologies, force of habit. I tend to work on Linux from time to time, and I prefer the forward slashes over the backwards ones. It's just so much easier to write down directories the Unix way compared to Windows! But to confirm, I am on Windows. The ~ refers to my C:\Users\{user} directory.
Anyways, I tried your technique of moving a created shortcut into the Sketchbook. I assumed you meant dragging the shortcut folder into the ~/Documents/Arduino/ directory via the explorer, but just in case I also tried dragging the shortcut directly into the sketchbook inside the Arduino IDE.
Neither of these seemed to work for me though. For completeness, I reproduced your steps in Windows Sandbox, where it yielded the same result as before. Are we perhaps on different builds? I'm unsure what the issue could be otherwise.
Please provide detailed step by step instructions I can follow to reproduce it.
It will be easiest if we can try to go as "vanilla" as possible for the symlink creation at this stage.
I'll install that "Symlink" package if it is absolutely necessary, but if we can use the standard commands that will remove one factor from the equation and make it easier for the developers to reproduce if it ends up that a formal bug report is needed.
Two things were not clear to me:
What is C:\Users\{user}\Documents\GitHub\bar\?
Is it a sketch?:
C:\Users\{user}\Documents\GitHub\
|_ bar
|_ bar.ino
|_ etc ...
Or is it a folder that contains sketches? For example:
There are several ways to open sketches in Arduino IDE 2.x:
File > Open...
File > Sketchbook
The Sketchbook view.
That is correct. The Explorer view is not part of the default primary Arduino IDE UI. The icon is added to the Arduino IDE Activity Bar only after you trigger the Explorer via the secondary UI.
Ah, good points. I'll keep them in mind for the future.
It will be easiest if we can try to go as "vanilla" as possible for the symlink creation at this stage.
Very valid, I've switched from the Symlink command to the New-Item command in Powershell, which should be a standard feature in Powershell. The command looked a little daunting at first, but on further inspection it's quite easy.
According to sterretje, is should also work with the Windows Create Shortcut feature, but I have not been able to make this work. I believe the mklink command should also work, but this is not Powershell compatible, and only works in the older Command Prompt cmd.exe of Windows. I have done any testing with mklink.
What is C:\Users\{user}\Documents\GitHub\bar\?
In the case I described from the initial post, the folder ../bar/ is a folder that contains multiple sketches. Might've been better to call it foo in that case...
In the meantime, I have tried to link a single sketch folder directly into the Sketchbook, but this yields the same result.
How did you open the sketch?
I'm trying to open the sketch via the Sketchbook view by double clicking the sketch.
I am able to open and edit the file using File > Open.... This does however remove the advantage of using the Sketchbook sidebar. The same holds for File > Sketchbook.
The reason is the different usage. sterretje is using File > Open...:
As you said, that works fine:
The problem is when using the "Sketchbook" view to open the sketch:
My experience is that the shortcut either doesn't show up at all in the Sketchbook view, or just shows up as a .lnk file you can't open depending on whether you have File > Preferences... > โ Show files inside Sketches enabled.
I found a different bad behavior when C:\Users\{user}\Documents\GitHub\bar\ is a sketch. In that case, it simply won't open from the Sketchbook view, and doesn't show up at all in the File > Sketch menu. I also got an unexpected dialog from File > Open:
The file "bar.ino" needs to be inside a sketch folder named as "bar".
Create this folder, move the file, and continue?
(unexpected because it was already inside a folder named bar)
With this information, I am able to reproduce the read-only bug you reported. I also am able to reproduce it on Linux (using ln -s to create the symlink).
The IDE editor is intended to make files read-only when they are outside the sketch folder. The reason is that the "Go to Definition" and "Peek" features allow the user to easily open library, core, and toolchain files in the IDE, which they might accidentally edit and cause a lot of confusion. It seems this system is wrongly triggered when the sketch is opened from under a symlinked folder.
So I think we have confirmed this is a bug. Please submit a report to the Arduino IDE developers here:
I didn't find any existing reports and I also verified that it occurs with the latest nightly build.