18

I am using geckodriver in the following code:

import time
from selenium import webdriver
from selenium.webdriver.firefox.options import Options
url = 'https://www.idealista.com/venta-viviendas/barcelona/eixample/la-dreta-de-l-eixample/?ordenado-por=fecha-publicacion-desc'
options = Options()
options.headless = False
driver = webdriver.Firefox(options=options, executable_path='/home/kevin/Desktop/Inmosoft/geckodriver')
driver.get(url)
time.sleep(10)

but everytime i try to execute i have this error:

enter image description here

I've tried to create another profile in firefox by using firefox -P following the information in this link https://support.mozilla.org/en-US/kb/how-run-firefox-when-profile-missing-inaccessible.

It looks like geckodriver is a complete different instance than firefox and it does not uses the same profile, how can i bypass this error and create a profile when using geckodriver?

Blackhole
  • 426
  • 3
  • 14

3 Answers3

18

I have had the same problem. In my case I am using ubuntu 22.04 and the problem is that firefox is installed by default with snap. The solution has been to uninstall firefox and install it without snap. Here is a link to do this.

remove snap firefox and install it as .dev

Ivan Rico
  • 191
  • 1
  • 4
8

TL/DR; Set a custom TMPDIR https://github.com/mozilla/geckodriver/issues/2010

Find the test that is booting the geckodriver and crashing e.g.

bundle exec rspec spec/features/sessions_spec.rb

When the job fails kill it via

ctrl+z # push job to background
kill %% # kill last job

# to kill all jobs do: sudo kill -9 `jobs -p -s`

Set a custom temporary directory via direnv like so:

# .envrc

export TMPDIR="$HOME/tmp/some-project"

You must create the directory via mkdir -p ~/tmp/some-project

Marlen T. B.
  • 664
  • 7
  • 12
  • Thank you! That fixed the issue for me. `TMPDIR="./tmp" gradle run` – pogopaule Aug 04 '22 at 16:24
  • 1
    This should be the accepted answer. There is no need to uninstall and reinstall firefox at all. Note that `TMPDIR` must be in the user home, setting it to `/tmp/blabla` doesn't work. – pieroxy Oct 25 '22 at 16:56
  • To be fair, I did kind of a bad job answering, in that I described how to solve the problem I had, rather than what the user was asking. The solution should probably be something like: "edit your ~/.bashrc and add TMPDIR=$HOME/tmp" – Marlen T. B. Oct 27 '22 at 00:15
  • Regarding Ubuntu 22.04 LTS, this is the right answer. Reinstalling the APT version of Firefox is not necessary. For details, see https://bugzilla.mozilla.org/show_bug.cgi?id=1766125 and https://github.com/mozilla/geckodriver/releases/tag/v0.31.0 Later versions of geckodriver (0.32.0) do not even require TMPDIR to be set, as they can detect the snap sandbox and place the temporary profile in another, suitable place. – Carsten Fuchs Feb 20 '23 at 13:05
  • They have now added a `--profile-root` argument to geckodriver: https://github.com/mozilla/geckodriver/issues/2010#issuecomment-1122739647 (For those who are running geckodriver manually) – Nitish Parkar Mar 08 '23 at 18:05
7

I solved the problem on Ubuntu 22.04 by using geckodriver from snap package. For example, I have directory $HOME/bin which is in the $PATH. From there I link firefox.geckodriver to $HOME/bin/geckodriver by

$ ln -s /snap/bin/firefox.geckodriver geckodriver

One can found location of firefox.geckodriver by

$ whereis firefox.geckodriver
jacaWaca
  • 71
  • 1
  • 2