On my ArchLinux number cruncher I have two accounts: A user account (benj) and the root account.
For administrative tasks I ssh into the machine using my user account. With the shell open, I switch to root using su .
Running emacs now shows an error that something went wrong during initialisation
Warning (initialization): An error occurred while loading ‘/home/benj/.emacs.d/init.el’:
File is missing: Cannot open load file, No such file or directory, ~/.emacs.d/init-modules/emacs-lisp-package-archive.el
To ensure normal operation, you should investigate and remove the cause of the error in your initialization file. Start Emacs with the ‘--debug-init’ option to view a complete error backtrace.
My ~benj/.emacs.d/init.el is modular while ~root/.emacs.d/init.el is not. I don't understand why emacs is trying to load my user's configuration file.
echo $HOME # Shows /root
alias | grep emacs # Shows nothing
which emacs # /user/bin/emacs
emacs --version # GNU Emacs 26.1
# Copyright (C) 2018 Free Software Foundation, Inc.
# GNU Emacs comes with ABSOLUTELY NO WARRANTY.
# You may redistribute copies of GNU Emacs
# under the terms of the GNU General Public License.
# For more information about these matters, see the file named COPYING.
However, when logging into root on TTY1 , M-x describe-variable on user-init-file returns the expected /root/.emacs.d/init.el
C-hig (emacs)Find Init says:
How Emacs Finds Your Init File
Normally Emacs uses the environment variable ‘HOME’ (*note HOME: General
Variables.) to find ‘.emacs’; that’s what ‘~’ means in a file name. If
‘.emacs’ is not found inside ‘~/’ (nor ‘.emacs.el’), Emacs looks for
‘~/.emacs.d/init.el’ (which, like ‘~/.emacs.el’, can be byte-compiled).
However, if you run Emacs from a shell started by ‘su’, Emacs tries
to find your own ‘.emacs’, not that of the user you are currently
pretending to be. The idea is that you should get your own editor
customizations even if you are running as the super user.
More precisely, Emacs first determines which user’s init file to use.
It gets your user name from the environment variables ‘LOGNAME’ and
‘USER’; if neither of those exists, it uses effective user-ID. If that
user name matches the real user-ID, then Emacs uses ‘HOME’; otherwise,
it looks up the home directory corresponding to that user name in the
system’s data base of users.
Related
I remember that when I first installed cygwin I could open files form my home directory using Windows applications. For example, I had Emacs installed in Windows and I could just do runemacs ~/some_file.txt. I had run out of space and had to move my cygwin installation to a different drive. Ever since then, I seem to have mucked up my installation and I can't use Windows applications like this anymore.
I have removed cygwin completely and re-installed it in C:\cygwin as before, but the problem remains.
I see that for some reason ~ gets expanded to C:\home\Tudor instead of C:\cygwin\home\Tudor.
Does anyone know how I could get this to work again?
Non-Cygwin Windows applications are not aware of your Cygwin root or home directory.
Emacs is a special case. It was originally developed on UNIX, and it uses UNIX-like syntax for some things.
According to your latest comment, Emacs expands ~ to C:\Users\Tudor. That's your Windows home directory, not your Cygwin home directory.
You can also install a Cygwin version of Emacs, which, like any Cygwin application, will expand ~ to your Cygwin home directory.
If you invoke a Windows application from a Cygwin shell, then the shell, not the Windows application, will expand ~ to your Cygwin home directory, expressed in Cgywin syntax. For example, assuming runemacs is a non-Cygwin application, if I run:
bash$ runemacs ~
then the shell expands the ~, so it's equivalent to (assuming my user name is Tudor):
bash$ runemacs /home/Tudor
runemacs will probably treat /home/Tudor as equivalent to \home\Tudor, which would be equivalent to C:\home\Tudor if the current drive is C:.
If you type Ctrl-X Ctrl-F from within Emacs to open a file, then Emacs will interpret ~ according to whatever rules it follows internally; those rules aren't likely to recognize Cygwin unless you're running a Cygwin version of Emacs or Emacs itself has some special-case code to handle Cygwin paths.
I work in an environment where we all log in as ourselves, then sudo to a common user. (Bleah). I'm starting to use emacs and would like to specify my own .emacs file at launch. What I think I want is to specify the location of .emacs with an environment variable, but I don't see any way to do that in the emacs documentation. Is there one?
As an alternative, perhaps I need to learn elisp and conditionally load my own file out of the common .emacs file located in /home/common_user/.emacs? In my case, I already have an environment variable SUDO_USER set to my name 'lcuff', and an environment variable MY_CONF set to /foo/bar/blah/lcuff, wherein I'd like to store my own .emacs file. How would I do this?
Thoughts and advice appreciated.
See:
C-hig (emacs) Find Init RET
Failing anything else, you can specify $HOME for a command with env:
env HOME=/foo/bar/blah/lcuff emacs
Invoking emacs with the -u option will seek the init file for the given user, so
emacs -u Leonard
will run emacs with your emacs initialization file, even if you are logged in as another user.
You can tell emacs to load the init file of your choice by saying:
emacs -q -l /path/to/my/preferred/.emacs
It's a little bit tricky working out who emacs thinks you are. From info:
More precisely, Emacs first determines which user's init file to use.
It gets your user name from the environment variables LOGNAME and
USER; if neither of those exists, it uses effective user-ID. If that
user name matches the real user-ID, then Emacs uses `HOME'; otherwise,
it looks up the home directory corresponding to that user name in the
system's data base of users.
So I'd start first with finding out who emacs thinks you are, by starting emacs
without loading any init files:
emacs -q
and then find out where emacs thinks your init file is:
(locate-user-emacs-file "yourrealusername")
I think on a fresh home environment it will default to
~/.emacs.d/yourusername, but that should help you decide where best to place
the init file.
An important point is that it's pretty good practice to have an emacs user
directory rather than just a startup file. There is a heap of extra guff
that emacs needs to keep track of (package management, customized settings,
backup files, dictionary, manually inserted lisp code etc etc) and I find it extremely useful to put all
this stuff in the one spot. Emacs looks in ~/.emacs.d/init.el if it doesn't
see ~/.emacs or ~/.emacs.el on the system. Make sure you don't have ~/.emacs
still.
Create a new file called ~/.emacs.d/init.el
Put this in it:
(setq user-emacs-directory "~/.emacs.d/")
(message "This is my init.el file and noone elses!!!")
(inhibit-default-init) ;; there might be a default.el lurking somewhere
If emacs got your username and home right, you can then restart with:
emacs -u therealme
or, if it stuffs up the environment variables
env HOME=/this/is/my/home USER=blah emacs
There just might be a site-start.el somewhere that might get loaded before
your init.el. If you suspect this, loading emacs with the --no-site-file
option will nuke this.
I have a Perl program that someone else created and I am calling on with CruiseControl. The program calls on Unix Commands using Cygwin. However, everytime that the Perl program calls on a Unix like command with a DOS like address, I get the well known error:
cygwin warning:
MS-DOS style path detected: E:\regression
Preferred POSIX equivalent is: /cygdrive/e/regression
CYGWIN environment variable option "nodosfilewarning" turns off this warning.
Consult the user's guide for more details about POSIX paths:
http://cygwin.com/cygwin-ug-net/using.html#using-pathnames
I have set both the User Variable AND System Variable CYGWIN to nodosfilewarning. This removes the error when I run the program from the command line, but the error still occurs in CruiseControl when called as an automated process from a batch file. I have called on both the batch file from the Desktop AND Command Line and ran as an administrator. Nothing changes.
Other Notes
For purposes of this problem, I don't have access to the Perl Program
I am trying to go back to Cygwin 1.5.*, but since I am using Server 2008, I am encountering compatibility issues
This is occurring on one of the distributed servers, not the main server running the Webdashboard.
I have read somewhere that this issue may stem from a different user calling on CruiseControl, but the issue should have been solved by setting this as an ENV System variable
Is it possible to modify the registery to set the ENV variables?
Thank you in advance
The way I do it is like this
printf 'export CYGWIN=nodosfilewarning' >> ~/.bash_profile
If CruiseControl is connecting to the server via ssh, reinstall sshd and explicitly include nodosfilewarning when prompted for the CYGWIN environment variable during the install.
Re-installing with modified environment will work but if you don't want to or cannot re-install, an alternative is to change the registry instead of re-installing the service.
See: CYGWIN windows cygrunsrv sshd server and MS-DOS style path detected
I have installed postgressql 8.4-91 version in my Linux OS.
On going to the directory where its installed I am able to locate psql in the directory.
I am having 2 issues.
on typing ./psql ,it asks for a password and doesn't accept any password.
On typibf psql i am getting " command not found"
The second one is easy. Most secure Linux system don't include . (the current directory) in the path (i.e., $PATH).
This avoids the attack vector of providing an ls script in your directory that will run if someone is foolish enough to have . before the real location of ls in their path.
If you really want to be able to run it without the dot, the safest option is to set up an alias like:
alias pg='./psql'
and then use pg to run it. I would advise against putting . in your $PATH variable, at least on a shared machine. If you're the only one able to muck about on your machine, then you could probably do it safely.
The first you can probably get around by editing the pg_hba.conf file to get rid of authentication, using alter user (or add user) to set up a password then turn authentication back on.
Or you could just run without authentication in your development environment, as so many of us do :-)
Hey, I'm trying to have a graphical program and I want it to start after I log in. How do I do so? I know there's a GUI program, but I want to use a command line here.
GUI tool:
http://www.thegeekstuff.com/2009/07/ubuntu-open-applications-automatically-during-system-startup/
now, there is update-rc.d, however, it seems to run before I log in, while the entire system loads ups (Unless I don't understand what the NN means in the update-rc.d manual).
Any ideas?
There's also an autostart folder in ~/.config/autostart - which is profile (or user) specific. If you put a .desktop file in /etc/xdg/autostart it will become a global startup for any new users created. This assumes you have xdg-user-dirs-gtk installed.
Drop a .desktop file in... /etc/xdg/autostart here, might be different on Ubuntu.