Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Command line requires X11 #1981

Closed
franky47 opened this issue Apr 1, 2014 · 46 comments
Closed

Command line requires X11 #1981

franky47 opened this issue Apr 1, 2014 · 46 comments
Labels
Component: CLI The Arduino IDE's command line interface Component: IDE The Arduino IDE Type: Bug

Comments

@franky47
Copy link

franky47 commented Apr 1, 2014

I'd like to use the CLI in Arduino 1.5 on a headless Raspberry Pi (accessed through SSH only, no X11 environment), to make a continuous integration platform.

When calling arduino in the command line, Java complains that the X11 environment is not set and is required (which should not be necessary for CLI programs).

CLI output:

$ arduino --verify foo.ino
Exception in thread "main" java.lang.ExceptionInInitializerError
    at processing.app.Base.main(Base.java:113)
Caused by: java.awt.HeadlessException: 
No X11 DISPLAY variable was set, but this program performed an operation which requires it.
    at sun.awt.HeadlessToolkit.getMenuShortcutKeyMask(HeadlessToolkit.java:231)
    at processing.core.PApplet.<clinit>(Unknown Source)
    ... 1 more
zsh: exit 1     arduino --verify foo.ino
@franky47 franky47 changed the title Command line requires GUI Command line requires X11 Apr 1, 2014
@matthijskooijman
Copy link
Collaborator

This seems related to #1970, but it's probably a separate problem. I'll put this on my list to investigate, thanks for reporting.

@matthijskooijman

@matthijskooijman
Copy link
Collaborator

Thinking about this a bit more, I think this will not be easy to fix. Right now, when running the CLI commands, all of the normal initialization happens normally,except for creating and showing the window. To fix this, we'd need to refactor the GUI code to be less coupled with the compilation functionality, which won't be very easy. We should do this eventually anyway, but this will probably require a significant effort.

@nkiest
Copy link

nkiest commented Jul 21, 2014

I'd like to comment that I have the same issue, and would love to be able to run the compile and upload commands via SSH (without X11).

@AleChelli
Copy link

Hi matthijskoijman same issue on a Debian Virtual Machine without GUI, I have try using arduino-mk, but doesn't work anyway...

@kashfshah
Copy link

Same issue with 1.5.8 on Debian Wheezy (Raspbian) running in a Raspberry Pi.

@raquelalegre
Copy link

Same issue - trying to do Continuous Integration on a Jenkins OS X node to verify Arduino files, but it needs to be headless. I've tried ino but it seems quite outdated. Is there any other workaround in the meanwhile? I've heard of bii hive, I'll give it a try too, but any other recommendations welcome.

Cheers,
Raquel

@ffissore
Copy link
Contributor

We use jenkins all the time. To workaround the needs of the IDE, we have installed https://wiki.jenkins-ci.org/display/JENKINS/Xvnc+Plugin

@raquelalegre
Copy link

Thanks so much @ffissore, I'll give it a try.

@raquelalegre
Copy link

Sorry if this is getting a bit off-topic. @ffissore, In which platform are your running that plugin? I'm trying to test Arduino verification on a Jenkins Mac node and after much configuring and working around, I've got stuck.

@ffissore
Copy link
Contributor

On mac we don't use that plugin because the node is launched via java web start. This allows the java process on mac node to access the display. Indeed, every once in a while, the IDE pops up and executes its functional tests

@raquelalegre
Copy link

I'm not sure I understand. Does that mean it's impossible to test this on a Mac node? :(

@ffissore
Copy link
Contributor

Quite the contrary. We do it all the time. But you need to start the mac node properly. I don't remember which tutorial I used to set it up, but the result is that our mac main user has a startup "start jenkins" app that connects to master using java web start

@raquelalegre
Copy link

Oh, I see. I'll google it! Thanks a lot!

@ffissore
Copy link
Contributor

Closing as wontfix. Fixing would require dismantling the IDE. We make small steps everyday, but can't really set a schedule

@ffissore ffissore added the Type: Wontfix Arduino has decided that it will not resolve the reported issue or implement the requested feature label May 28, 2015
@ffissore ffissore added this to the Release 1.6.5 milestone May 28, 2015
@ffissore ffissore self-assigned this May 28, 2015
@wtgee
Copy link

wtgee commented Aug 20, 2016

Ugh, how is this still an issue? Workaround above still assumes java display. export JAVA_TOOL_OPTIONS='-Djava.awt.headless=true' doesn't help, even with #5132 as you still get an error on the splash screen. Is there no way to compile and upload a sketch on a headless display?

@szafran81
Copy link

Still not fixed... unfortunatelly.

@mxxxc
Copy link

mxxxc commented Nov 4, 2016

Bumping this as it affects us too, running the CLI on an embedded device we would really prefer not having to run Xvfb to flash an attached board. 😄

@franky47
Copy link
Author

franky47 commented Nov 4, 2016

FYI, as @wollew suggested, I switched to PlatformIO which can perform headless builds and uploads of Arduino sketches. For those who can run Python in their headless environment, it can be a temporary workaround. It works a wonder for Travis testing for example.

@q2dg
Copy link

q2dg commented Nov 5, 2016

It's very ironic multi-target PlatformIO framework can do it and official Arduino-only IDE can't. Oh, my

@cmaglie
Copy link
Member

cmaglie commented Nov 7, 2016

It's very ironic multi-target PlatformIO framework can do it and official Arduino-only IDE can't. Oh, my

Irony aside, I would like to point out the amount of work needed to achieve that. The Arduino IDE is a fork of Processing that has been designed from the beginning as a GUI application: it surely requires much more work to obtain a "pure" CLI application compared to an application that... well... is born as command line utility! :-)
Consider also that the amount of users that runs the IDE from CLI is a small minority (and who is using it "head-less" on Linux is even a share of them), that's why this issue has not been our top priority, given also the fact that a simple workaround exists.

Anyway, I've just pushed #5578 that should solve this issue once for all.

@njh
Copy link

njh commented Nov 7, 2016

Thank you very much for your efforts on this @cmaglie

It will be really good to be able to verify Arduino builds automatically, using the official toolchain.

@q2dg
Copy link

q2dg commented Nov 8, 2016

Sorry if I've been rude, that wan't my intention...I was only amazed. I apologize
As @njh has said, thank you very much for your excellent work on this and on any other issue, @cmaglie.

@cmaglie cmaglie added this to the Release 1.6.14 milestone Nov 25, 2016
@NicSil
Copy link

NicSil commented Apr 10, 2017

"Consider also that the amount of users that runs the IDE from CLI is a small minority"
Considering all the above, how many did you expected?

@cmaglie
Copy link
Member

cmaglie commented Apr 10, 2017

"running-arduino-cli-from-a-headless-linux-machine" hits <0.01% of our user base that is mostly Windows / Mac with a desktop PC. BTW now it's fixed, there is no point in discussing this further.

@merwok
Copy link

merwok commented Apr 10, 2017

Thanks for this work! It will enable all sorts of things from letting people use their favourite text editor or IDE for arduino code to automated rebuilds and deploy.

@ianfixes
Copy link

I'm still noticing the need for this X11 workaround as recently as the 1.8.5 build, as part of development work on a Continuous Integration system for Arduino (https://github.com/ianfixes/arduino_ci).

In addition to what I assume was the splash screen popping up, some errors were presented graphically instead of via the console, which caused a hang -- waiting for a graphical "ok" before continuing.

Is there a command line switch I'm missing?

@CRCinAU
Copy link

CRCinAU commented Jul 12, 2018

I notice this too with 1.8.5 - even if I run with X Forwarding - as thousands of other apps run fine.

$ arduino
Gtk-Message: 12:07:10.935: GtkDialog mapped without a transient parent. This is discouraged.
java.awt.HeadlessException
        at java.awt.SplashScreen.getSplashScreen(SplashScreen.java:117)
        at processing.app.Base.<init>(Base.java:206)
        at processing.app.Base.main(Base.java:135)

@GammaSQ
Copy link

GammaSQ commented Aug 6, 2018

I'm running fedora 27 within QubesOS. This issue didn't happen earlier, though I haven't used the arduino IDE within the last year.
Error message:

$ arduino
java.awt.HeadlessException
    at java.awt.SplashScreen.getSplashScreen(SplashScreen.java:117)
    at processing.app.Base.<init>(Base.java:206)
    at processing.app.Base.main(Base.java:135)

dnf info arduino output:

Name         : arduino
Epoch        : 1
Version      : 1.8.5
Release      : 4.fc27
Arch         : noarch
Size         : 3.0 M
Source       : arduino-1.8.5-4.fc27.src.rpm
Repo         : @System
From repo    : updates
[... description, license, ASO redacted for brevity]

@per1234
Copy link
Collaborator

per1234 commented Aug 6, 2018

@GammaSQ it appears you're using a version of the Arduino IDE installed via a package manager. It has been modified in unknown ways by 3rd parties, which might be the cause of the problem. I recommend removing that thing and trying the official Arduino IDE downloaded from:
https://www.arduino.cc/en/Main/Software

@cmaglie
Copy link
Member

cmaglie commented Aug 8, 2018

@GammaSQ @CRCinAU
running just arduino will launch the Arduino IDE (the GUI), you need to provide some command to actually do something (complie / verify / upload...)

@ianfixes
which exact command are you running? Please post in another issue with instructions to reproduce.

@darrahts
Copy link

darrahts commented Aug 9, 2018

#5578 says it fixed this, however running arduino on raspbian stretch still gives the error.

No X11 DISPLAY variable was set, but this program performed an operation which requires it.
at sun.awt.HeadlessToolkit.getMenuShortcutKeyMask(HeadlessToolkit.java:236)
at processing.core.PApplet.(Unknown Source)
... 3 more

@cmaglie
Copy link
Member

cmaglie commented Aug 9, 2018

@darrahts which command did you launch?

@darrahts
Copy link

darrahts commented Aug 9, 2018

Arduino 2:1.0.5

arduino --upload ../controllerWithDCmotorsNetsblox/controllerWithDCmotorsNetsblox.ino --port /dev/ttyACM0

also tried the arduino-headless trick but it just hung (although no error messages, but hanging is an error itself)

@cmaglie
Copy link
Member

cmaglie commented Aug 9, 2018

You're running Arduino 1.0.5, now we are at 1.8.5.

Please remove the package coming from raspbian repositories that is very old, and download the latest from arduino.cc.

@ianfixes
Copy link

ianfixes commented Aug 9, 2018

@cmagile I'll swear on my life that I saw this problem on 1.8.5 but I just ran the full suite of tests on my CI library in linux, via Travis with the xdpy display manager hack turned off, and it works fine.

Can't repro. Will open a new issue if it ever happens again.

Thanks for following up!

@darrahts
Copy link

Yes that would make a big difference (sorry for the oversight!), however I'm still having issues. on a fresh sudo apt-get install arduino -y I still received the same error, and obviously couldnt run arduino --version to verify the version. Then, going to arduino.cc and downloading the linux arm tar.bz file, left me with this:

Adding desktop shortcut, menu item and file associations for Arduino IDE...touch: cannot touch '/root/.local/share/applications/mimeapps.list': No such file or directory
/usr/bin/xdg-mime: 803: /usr/bin/xdg-mime: cannot create /root/.local/share/applications/mimeapps.list.new: Directory nonexistent
done!

running it without sudo I get this:

touch: cannot touch '/home/pi/.local/share/icons/hicolor/.xdg-icon-resource-dummy': No such file or directory
touch: cannot touch '/home/pi/.local/share/icons/hicolor/.xdg-icon-resource-dummy': No such file or directory
touch: cannot touch '/home/pi/.local/share/icons/hicolor/.xdg-icon-resource-dummy': No such file or directory
touch: cannot touch '/home/pi/.local/share/icons/hicolor/.xdg-icon-resource-dummy': No such file or directory
touch: cannot touch '/home/pi/.local/share/icons/hicolor/.xdg-icon-resource-dummy': No such file or directory
touch: cannot touch '/home/pi/.local/share/icons/hicolor/.xdg-icon-resource-dummy': No such file or directory
touch: cannot touch '/home/pi/.local/share/icons/hicolor/.xdg-icon-resource-dummy': No such file or directory
touch: cannot touch '/home/pi/.local/share/icons/hicolor/.xdg-icon-resource-dummy': No such file or directory
touch: cannot touch '/home/pi/.local/share/icons/hicolor/.xdg-icon-resource-dummy': No such file or directory
touch: cannot touch '/home/pi/.local/share/icons/hicolor/.xdg-icon-resource-dummy': No such file or directory

I am on a fresh install of raspbian stretch. This looked similar to #6116 but the RESOURCE_NAME is already arduino-arduinoide

@matthijskooijman
Copy link
Collaborator

sudo apt-get install arduino -y

@darrahts, that will likely get you an 1.0.5 version, which is the "latest" from Debian. Better get the zipfile from arduino.cc directly (there is an ARM/rpi version).

@PetrKosvanec
Copy link

Hello,

Thank you for Arduino.

I had installed Arduino IDE on RHEL days ago, in Dec 2021. Uploading sketches in the (RHEL) user account is blocked. So in user account in shell/terminal I typed "su -" followed by root password, to get root privileges (temporarily) for the time I will be in arduino IDE, as recommended by Red Hat due to security. Then, from the terminal I've fired the Arduino IDE up, getting this same issue:

[root@localhost ~]# arduino
Picked up JAVA_TOOL_OPTIONS:
Set log4j store directory /root/.arduino15
java.awt.HeadlessException:
No X11 DISPLAY variable was set, but this program performed an operation which requires it.
at java.awt.SplashScreen.getSplashScreen(SplashScreen.java:117)
at processing.app.Base.(Base.java:246)
at processing.app.Base.main(Base.java:150)

dnf info arduino
output is:

Available Packages
Name : arduino
Epoch : 1
Version : 1.8.5
Release : 3.fc28
Architecture : noarch
Size : 2.1 M
Source : arduino-1.8.5-3.fc28.src.rpm
Repository : dl.fedoraproject.org_pub_archive_fedora_linux_releases_28_Everything_x86_64_os
...

The only workaround I am aware of is to switch RHEL from user to root (discouraged by Red Hat as insecure). Fire up the IDE from there, and use it.

"Headless mode is a system configuration in which the display device, keyboard, or mouse is lacking." - that is not how I use this notebook. But I program bits and pieces on this machine, using various openjdk and java_sdk vers. I would be grateful if you can point me to other workaround(s); I doubt Xvnc si possible solution for me to look at (I've just read DESCRIPTION of 'man Xvnc'). "Virtual Network Computing is a graphical desktop-sharing system that uses the Remote Frame Buffer protocol to remotely control another computer. It transmits the keyboard and mouse input from one computer to another, relaying the graphical-screen updates, over a network." - does not look like what I need.

Obviously I can live with the current situation and fully understand that I fall into a very small userbase set. No answer from you is fine, too, and would affirm my understanding the solution would require too extensive a work given our small specific userbase.

Thank you for Arduino. Appreciating your work, Arduino beginner Petr Kosvanec.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Component: CLI The Arduino IDE's command line interface Component: IDE The Arduino IDE Type: Bug
Projects
None yet
Development

No branches or pull requests