PhpStorm in Ubuntu can't detect pd_dump executable on PostgreSQL Export - postgresql

My environment:
Ubuntu 20.04.3 LTS on Windows 10
-> https://www.microsoft.com/store/productId/9NBLGGH4MSV6
PhpStorm 2022.1 Build #PS-221.5080.224, built on April 13, 2022
My Problem:
I'm trying to export a PostgreSQL database inside the Database tab of PhpStorm.
To execute the export I right click the database in the list and click on the "Export with 'pg_dump'" option. This opens the Export window with all the options and command preview:
Inside of the window I get the error message "Path to executable is wrong" even tho the pg_dump file exists at the given path /usr/bin/pg_dump. This stops me from executing the export.
I have tried to manually install pg_dump in another directory and select it in the PhpStorm Export window, but it still won't detect the executable. The executable itself works fine.

The solution to this problem was to do a sudo apt-get install postgresql-client.
Apparently there is a general problem with the pg_dump executable of the "postgresql-client-common" package:
https://askubuntu.com/questions/501091/command-pg-dump-not-found
After installing the postgresql-client package, everything works fine in PhpStorm as well.

The code is pretty simple there: IDE checks that file exists and is executable, then run /path/to/pg_dump --version command and parse output looking for some keywords. Unfortunately there are no logs which can show exact reason, but I guess the issue that IDE can't get access to the file. Most likely due to WSL. The workaround is to install IDE and unpack PG binaries on Windows, then configure port forwarding to make PG server accessible from host OS.

Related

How do I install the Matlab MCR in Ubuntu 14.04 without "killing" Unity?

Background: I have created an Ubuntu VirtualBox from LAPP stack and added the Ubuntu desktop (Unity: sudo apt-get install ubuntu-desktop). Now I am attempting to install the MCR without loosing Unity.
Download MCR zip and extract to MCR_SOURCE
Go to my folder that contains the files: cd /media/sf_shared/MCR_ SOURCE
Change installer_input.txt file:
destinationFolder=/opt/MCR
agreeToLicense=yes
outputFile=/opt/install.log
mode=silent
product.MATLAB
product.MATLAB_Builder_JA
# Note: To find out the required toolboxes >> start Matlab >> run your code and find out which toolboxes were used with: license('inuse')
Install MCR: sudo ./install -inputFile /media/sf_shared/MCR_SOURCE/installer_input.txt >> success
Restart Ubuntu >> test whether Ubuntu’s Unity still exists >> everything is fine
Attention the next step will “ kill ” your Ubuntu desktop configuration!!! (i.e. copy your hardisk, anything you must do to recover quickly) – now configure: sudo gedit /etc/environment
LD_LIBRARY_PATH="/opt/MCR/v84/runtime/glnxa64:/opt/MCR/v84/bin/glnxa64:/opt/MCR/v84/sys/os/glnxa64:${LD_LIBRARY_PATH}"
XAPPLRESDIR="/opt/MCR/v84/X11/app-defaults"
# Note: X11/app-defaults folder has not been created during installation
Restart Ubuntu >> Unity is gone, recovery attempts such as deleting the above lines do not recover Unity; reinstalling the Ubuntu desktop does not help either.
I have tried an alternative route with exporting the variables, which also "kills" Unity. By the way this affects all users.
Any ideas?
It is not necessary to register these environment variables in /etc/environment, which means that the Unity sidebar will not be affected.
Instead register the environment variables temporarily either as local user or via sudo -i:
export LD_LIBRARY_PATH="/opt/MCR/v84/runtime/glnxa64:/opt/MCR/v84/bin/glnxa64:/opt/MCR/v84/sys/os/glnxa64:${LD_LIBRARY_PATH}"
export XAPPLRESDIR="/opt/MCR/v84/X11/app-defaults"
Now it is possible to run Matlab Apps without "killing" Ubuntu's desktop. For instance to run the Java compiled makesqr.m file.
java -classpath "/opt/MCR/v84/toolbox/javabuilder/jar/javabuilder.jar:/media/sf_shared/for_testing/makesqr.jar" makesqr.Class1 5
The Java package makesqr was created using Matlab's JavaBuilder tutorial. This was done on my Windows 7 machine, which runs Matlab R2014b.
Please ensure that the owner and permissions of the /opt/MCR and /media/sf_shared/for_testing folders are set correctly (see here for details).

change which psql launches on startup

I installed brew install postgresql , which was fine and worked well.
I then installed brew install postgresql8 as I wanted to check some postgres 8 specific things.
I then uninstalled postgresql8, however when I restart my mac, and run which psql, it still defaults to
/opt/local/lib/postgresql83/bin/psql
How can I change this back to default to the latest 9.x psql?
The executable which launches is dependent on PATH-variable and which-command makes its checks based on that variable also. The contents of the PATH-variable depend on different things. You can find more info in here for example.
You can launch the right psql by writing the full path on the command line, for example:
~$ /opt/local/lib/postgresql94/bin/psql

I installed PostgreSQL on mavericks, but running `which psql` does not do anything. Did it install correctly?

I installed PostgreSQL using the downloadable graphic installer. I'm able to launch pgAdmin which is PostgreSQL's GUI. However, when I run which psql on the terminal, I'm not getting any path (and based on what I read here it should yield a path provided postgres successfully installed).
After looking at this Stackoverflow post, I should have done it via homebrew. Should I uninstall the PostgreSQL that I got via the graphic installer, and re-install using homebrew?
Noob here, and I appreciate your patience.
If you've installed it using Postgres.app, the path to your binary should be under /Applications/Postgres.app/. Try running this at the terminal, you can see on my system it's under /Applications/Postgres.app/Contents/MacOS/bin.
$: find /Applications/Postgres.app/ -name "psql" -print
/Applications/Postgres.app/Contents/MacOS/bin/psql
If you then want to add this to your path variable, you could use this tutorial.

Installed Postgres.app but it won't work

I just installed Postgres.app on my Mac but it won't work properly. I finished the installation and the app icon is on the menu bar and it says it is listening on port 5432, however, that is what happens if I try to run it from the command-line:
~ $ psql
zsh: correct 'psql' to 'sl' [nyae]? n
zsh: command not found: psql
I had previously installed PostgreSQL via Homebrew but removed it before installing Postgres.app. I am running Mac OS X Lion.
I appreciate any help, I really want to have PostgreSQL running on my machine.
The psql binary for Postgres.app is inside the application bundle and you'll have to add the appropriate directory to your PATH. From the fine manual:
Configure your $PATH
Postgres.app includes many command line tools. If you want to use them, you must configure the $PATH variable.
If you are using bash (default shell on OS X), add the following line to ~/.bash_profile:
export PATH=$PATH:/Applications/Postgres.app/Contents/Versions/latest/bin
[...]
So adjust your PATH setting in your zsh config files to include the
Contents/Versions/latest/bin
directory inside your Postgres.app bundle.
I'm reading this as of April 2014 and the directory you must include in your path as far as my Postgres app is concerned is slightly different.
I had to include this:
PATH="/Applications/Postgres.app/Contents/Versions/9.3/bin:$PATH"
I can now run psql in my terminal.
On zsh shell you have the modify .zshrc:
PSQL_PATH="/Applications/Postgres.app/Contents/Versions/latest/bin"
PATH="$PATH:$PSQL_PATH"
On prompt:
exec $SHELL
which psql
What you should do is to use /latest instead of version so you dont need to change it again when updating Postgres.
How to: http://postgresapp.com/documentation/cli-tools.html
then run:
. ~/.bash_profile
to reload .bash_profile and update any functions you add.
This might seem stupid, but I'm curious where you installed Postgres.app? As was suggested in mu is too short's answer, the documentation mentions adding /Applications/Postgres.app/Contents/MacOS/bin to your path. However, this requires that you have installed Postgres.app in your /Applications/ folder.
Before trying any of the more complicated solutions you might have found on Stack Overflow, and other resources via Google, you should make sure you've installed Postgres.app to the right place. It may be as simple as moving Postgres.app to /Applications/ since psql will be found in /Applications/Postgres.app before any other places.
Alternatively, you could use whatever path to Postgres.app you would like. So if you want it in your home directory, then you could use export PATH="~/Postgres.app/Contents/MacOS/bin:$PATH".
HTH
I'm a previous Ubuntu user, now in OSX Trying to run the "which sql" and "pg_restore" commands directly from a terminal I opened didn't work. I clicked on the elephant icon and opened a terminal by "Open psql". Once I've quit from the psql console and written the commands in that terminal, they all worked.
On ZSH terminal, before trying the above solutions you have to install Postgres in the first place. While using Hombrew
First, hit,
brew install postgres Then check if it is installed by which psql

Can't install PostgreSQL: An error occurred executing the Microsoft VC++ runtime installer on Windows XP

I downloaded installer postgresql-9.0.1-1-windows.exe from the official site, ran it, and then got an error:
An error occurred executing the Microsoft VC++ runtime installer
What is the reason for this error message?
Platform: Windows XP SP3, Dell Inspiron 1501. Processor: AMD Sempron 3500+
One of the reasons this can happen is because the installer attempts to install an older version of the VC++ runtime than what you are currently using.
See this installation log, found in your user's temporary directory (e.g. dd_vcredist_amd64_20190214193107.log):
[20C0:20E4][2019-02-14T19:31:07]e000: Error 0x80070666: Cannot install a product when a newer version is installed.
A workaround is to prevent the runtimes from installing with the --install_runtimes option:
postgresql-9.6.12-1-windows-x64.exe --install_runtimes 0
Create a shortcut of the downloaded file:
Right click of the shortcut → Properties → Shortcut. Add --install_runtimes 0 to the end of the file path:
Create a shortcut of your EXE file;
right click on the shortcut → add --install_runtimes 0 at the end of the target path, e.g.:
postgresql-9.3.1-1-windows-x64.exe --install_runtimes 0
save and run it :)
I was having a similar issue and found a fix that worked for me from Garrett_H in this forum post:
http://forums.enterprisedb.com/posts/list/1747.page#6180
Go to file %windir%\inf\wsh.inf, right click and select 'Install'
re-run postgresql installer
I'm running Windows XP Pro, and I was trying to install postgresql-8.3.17-1-windows.exe. I originally received the following error:
An error occurred executing the Microsoft C++ runtime installer.
First download and install Microsoft Visual C++ from the Microsoft website. Then run the installation from command with --install_runtimes 0.
In my case, when I was installing postgresql-11.0-1-windows-x64.exe on Windows 10, I had faced the same problem.
I just uninstalled the Microsoft Visual C++ Redistributable (the latest one for both 32 and 64 bit) and then tried to install postgresql-11.0-1-windows-x64.exe again, and it worked for me.
I too faced the same issue. I fixed it in the following way:
I visited the below site:
https://www.enterprisedb.com/downloads/postgres-postgresql-downloads
Choose the Download button under PostgreSQL Version 11.1 for Windows x86-64.
In one word, just try to install the latest version.
Try installing as administrator (using Run as administrator).
In version 9.0. PostgreSQL can be installed as a Windows administrator :)
Check if Windows Script Host (WSH) is enabled. If not enabled, details are here: PostgreSQL Installation Problem on Windows without WSH
Take special care that your Windows user's folder name does not contain spaces. PostgreSQL (as of version 9.2.2.1) handles that poorly. If I use this account on Windows XP, installation fails with the "An error occurred executing the Microsoft C++ runtime installer" message:
"C:\Documents and settings\Jimmy (admin)"
But it runs just fine with this:
"C:\Documents and settings\Jimmy-admin"
The spaces in "Documents and settings" don't seem to bother the installer. Go figure.
Go to file %windir%\inf\wsh.inf, right click, and select 'Install'.
Then re-run the PostgreSQL installer.
This works on Windows XP with PostgreSQL 8.4.17-1.
Windows Script Host (WSH) is unable to execute VBScript scripts. This can occur if the scripting host is disabled (which is unusual), or if the installation is broken. A sign of this problem is a message like
CScript Error: Can't find script engine "VBScript" for script "C:....
It can often be resolved by re-registering the VBScript interpreter, click Start * → * Run and enter the following and click OK:
regsvr32 %systemroot%\system32\vbscript.dll
I had the same problem while trying to install PostgreSQL version 11.1. I had to uninstall the Microsoft VC++ and run the installer again. It downloaded the required VC++ and the installation went successful.
I had these same problems and tried
manually installing MS VC++
bypassing VC++ installation on postgres
fixing windows update service
Still unsuccessful
Then I solved these problem by installing postgres manually:
extract the PostgreSQL installation contents to C:\PostgreSQL (you can copy from successful installation on other machines)
add C:\PostgreSQL\bin to PATH environment
run pg_ctl register -D D:\pgdata -N postgresql -U postgres -P <your postgres password>