Description: <short summary of the patch>
 TODO: Put a short summary on the line above and replace this paragraph
 with a longer explanation of this change. Complete the meta-information
 with other relevant fields (see below for details). To make it easier, the
 information below has been extracted from the changelog. Adjust it or drop
 it.
 .
 ess (17.11-3) unstable; urgency=medium
 .
   * debian/emacsen-install: Allow 'emacs' 		(Closes: #906517)
Author: Dirk Eddelbuettel <edd@debian.org>
Bug-Debian: https://bugs.debian.org/906517

---
The information above should follow the Patch Tagging Guidelines, please
checkout http://dep.debian.net/deps/dep3/ to learn about the format. Here
are templates for supplementary fields that you might want to add:

Origin: <vendor|upstream|other>, <url of original patch>
Bug: <url in upstream bugtracker>
Bug-Debian: https://bugs.debian.org/<bugnumber>
Bug-Ubuntu: https://launchpad.net/bugs/<bugnumber>
Forwarded: <no|not-needed|url proving that it has been forwarded>
Reviewed-By: <name and email of someone who approved the patch>
Last-Update: 2018-08-18

--- ess-17.11.orig/lisp/ess-site.el
+++ ess-17.11/lisp/ess-site.el
@@ -75,13 +75,22 @@
   ;; A nice default
   (directory-file-name
    (file-name-directory
-    (if (and (boundp 'load-file-name) load-file-name)
+    (if load-file-name
         (file-truename load-file-name)
       (locate-library "ess-site") )))
   "Directory containing ess-site.el(c) and other ESS lisp files.")
 
+(defvar ess-etc-directory nil
+  "Location of the ESS etc/ directory.
+The ESS etc directory stores various auxillary files that are useful
+for ESS, such as icons.")
+
+
+;; Depending on how ESS is loaded the `load-path' might not contain
+;; the `lisp' directory. For this reason we need to add it before we
+;; start requiring ESS files
 (add-to-list 'load-path (file-name-as-directory ess-lisp-directory))
-(require 'ess-utils);; <<- _not_ in load-path typically for traditional setup
+(require 'ess-utils)
 
 (ess-message (format "[ess-site:] ess-lisp-directory = '%s'" ess-lisp-directory))
 
--- ess-17.11.orig/lisp/ess-utils.el
+++ ess-17.11/lisp/ess-utils.el
@@ -35,7 +35,11 @@
 ;;*;; Internal ESS tools and variables
 
 (defvar ess-lisp-directory
-  (directory-file-name (file-name-directory (locate-library "ess-site")))
+  (directory-file-name
+   (file-name-directory
+    (if load-file-name
+        (file-truename load-file-name)
+      (locate-library "ess-utils") )))
   "Directory containing ess-site.el(c) and other ESS lisp files.")
 
 (defvar ess-etc-directory nil
@@ -43,25 +47,24 @@
 The ESS etc directory stores various auxillary files that are useful
 for ESS, such as icons.")
 
-(defvar ess-etc-directory-list
-  '("../etc/ess/" "../etc/" "../../etc/ess/" "./etc/")
-  "List of directories, relative to `ess-lisp-directory', to search for etc.")
-
-(while (and (listp ess-etc-directory-list) (consp ess-etc-directory-list))
-  (setq ess-etc-directory
-        (expand-file-name (concat ess-lisp-directory "/"
-                                  (car ess-etc-directory-list))))
-  (if (file-directory-p ess-etc-directory)
-      (setq ess-etc-directory-list nil)
-    (setq ess-etc-directory nil)
-    (setq ess-etc-directory-list (cdr ess-etc-directory-list))
-    (when (null ess-etc-directory-list)
-      (beep 0) (beep 0)
-      (message (concat
-                "ERROR:ess-site.el:ess-etc-directory\n"
-                "Relative to ess-lisp-directory, one of the following must exist:\n"
-                "../etc/ess, ../etc, ../../etc/ess or ./etc"))
-      (sit-for 4))))
+;; Try to detect the `etc' folder only if not alread set up by distribution
+(unless ess-etc-directory
+  (let ((path-list '("../etc/ess/" "../etc/" "../../etc/ess/" "./etc/")))
+    (while (and (listp path-list) (consp path-list))
+      (setq ess-etc-directory
+            (expand-file-name (concat ess-lisp-directory "/"
+                                      (car path-list))))
+      (if (file-directory-p ess-etc-directory)
+          (setq path-list nil)
+        (setq ess-etc-directory nil)
+        (setq path-list (cdr path-list))
+        (when (null path-list)
+          (beep 0) (beep 0)
+          (message (concat
+                    "ERROR:ess-etc-directory\n"
+                    "Relative to ess-lisp-directory, one of the following must exist:\n"
+                    "../etc/ess, ../etc, ../../etc/ess or ./etc"))
+          (sit-for 4))))))
 
 (defun ess-message (format-string &rest args)
   "Shortcut for \\[message] only if `ess-show-load-messages' is non-nil."
