Menu

#25 No known root for source-tree (default tree)

v2.0
open
nobody
None
5
2016-08-30
2016-06-20
No

Hi,

Initially I have installed the LXR for a source from git repository with Apache2 and postgres and it all worked perfectly fine.

Then I wanted to replace the Apache2 with Nginx, installed nginx, configured with provided configuration file but it is showing the following error when I access http://localhost/ref/source.

Unrecoverable error
No known root for source-tree (default tree)

If there is no typo in its name, you should consider waiting for it to be put online. Meanwhile, why not take a book and relax?

This page was automatically generated by the 2.1.0 LXR engine. The LXR team
Valid CSS 2.1! Valid HTML 4.01!

My default configuration in /etc/nginx/sites-available/default is as bellow.

# Default server configuration
#

server {
    listen 80 default_server;
    root /var/www/html;
    index index.html;

    server_name  localhost
                 163.33.210.59
    ;

    location ~ ^/ref/(.*)$
    {
        alias /usr/local/share/lxr/$1;

        location ~ ^(/ref/)(diff|ident|search|showconfig|source)
        {
            set $virtroot    $1;
            set $script_name $2;
            gzip off; #gzip makes scripts feel slower since they have to complete before getting gzipped

            alias /usr/local/share/lxr/;

            # Create FastCGI environment for LXR scripts
            include fastcgi.conf;
            fastcgi_split_path_info   (diff|ident|search|showconfig|source)(.*)$;

            fastcgi_param SERVER_NAME      $host;
            fastcgi_param SCRIPT_FILENAME  $document_root$script_name;
            fastcgi_param SCRIPT_NAME      $virtroot$script_name;
            fastcgi_param PATH_INFO        $fastcgi_path_info;
            fastcgi_pass  unix:/var/run/fcgiwrap.socket;
        }
    }

    location ~ /\.ht {
        deny all;
    }
}

The /var/log/nginx/error.log shows the following error.

2016/05/19 08:17:27 [error] 27974#27974: *5 open() "/var/www/html/source/templates/lxr.css" failed (2: No such file or directory), client: 127.0.0.1, server: localhost, request: "GET /source/templates/lxr.css HTTP/1.1", host: "localhost", referrer: "http://localhost/ref/source"
2016/05/19 08:17:27 [error] 27974#27974: *5 open() "/var/www/html/source/LXRimages/vcss.gif" failed (2: No such file or directory), client: 127.0.0.1, server: localhost, request: "GET /source/LXRimages/vcss.gif HTTP/1.1", host: "localhost", referrer: "http://localhost/ref/source"
2016/05/19 08:17:27 [error] 27974#27974: *5 open() "/var/www/html/source/LXRimages/valid-html401.png" failed (2: No such file or directory), client: 127.0.0.1, server: localhost, request: "GET /source/LXRimages/valid-html401.png HTTP/1.1", host: "localhost", referrer: "http://localhost/ref/source"
2016/05/19 08:17:27 [error] 27974#27974: *5 open() "/var/www/html/source/templates/lxr.css" failed (2: No such file or directory), client: 127.0.0.1, server: localhost, request: "GET /source/templates/lxr.css HTTP/1.1", host: "localhost", referrer: "http://localhost/ref/source"

I would really appreciate if anybody could help me here.

Thanks,
Awal.

Discussion

  • Andre-Littoz

    Andre-Littoz - 2016-06-20

    Hi Awal,

    I compared your NginX configuration with mine and it looks correct, at leat as far as I can check without knowing your directory structure.

    Since you get "No known root ...", NginX launched the LXR scripts as FastCGI and their output was sent to the browser. We can assume that NginX is correctly configured and is working.

    From the error log, NginX tries to fetch the auxiliary files (CSS sheet, images, ...) from /var/www/html/source instead of /usr/local/share/lxr. This suggests an incorrect root in the server { } block.

    As a quick-and-dirty check, change your root directive to

    root /usr/local/share/lxr
    

    Of course, if you have other non-LXR pages in your site, they become inaccessible, but this is only a test. If it works, then the alias directives will have to be tweaked. If it still does not work, something is wrong in lxr.conf and I'll check later.

    Give me feedback,
    ajl

     
    • reshma begam pattan

      Hi Andre,

      I am Reshma, I am taking care of this ticket on behalf of Awal.

      have tried suggest change in /etc/nginx/sites-available/default but it didnot solve the issue.
      I aded some debug prints inside the lib/LXR/Common.pm and lib/LXR/Template.pm and i got below prints on my webpage when I try to access the URL with ip address.
      URL: http://163.33.210.59:8080/ref/source

          Reshma1: http://localhost:8080/source/ 
          Reshma2: LXR::Config=HASH(0x13f9cd8) 
          Reshma3: http://localhost:8080/source/
      
       code snippet with debug prints
          sub baseurl {
                  (my $url = $config->{'baseurl'}) =~ s!/*$!/!;
                  printf("Reshma1: %s\n", $url);
                  printf("Reshma2: %s\n", $config);
                  $url =~ s/([\?\&\;\=\'\"])/sprintf('%%%02x',(unpack('c',$1)))/ge;
                  return $url;
          }
      
          sub makeerrorpage {
                  printf("Reshma3: %s\n", &baseurl);
                  my $who = shift;
                  my $tmplname;
                  my $template;
      

      I feel debug prints are printing wrong URL, that means some configuration issue.

      I have attached a file which contains lxr.conf, nginx-server-conf (i.e. /etc/nginx/sites-available/default) and debug logs of nginx which you can compare and let me know what is the config issue.

      Thanks,
      Reshma

       
  • Andre-Littoz

    Andre-Littoz - 2016-06-20
    • labels: No known root for source-tree -->
    • Group: Support needed --> v2.0
     
  • Andre-Littoz

    Andre-Littoz - 2016-06-22

    Hi Reshma,

    I see nothing unusual in your lxr.conf. Your nginx configuration looks equally pretty good.

    Since you get the error page with "No known root ...", this means the LXR scripts and its library is correctly referenced and operates as expected.

    The message "No know root ..." tells that LXR has no access to your tree. A non-existent tree is surely a good reason, but this is not your case as you have it in a git repository.

    The most frequent cause for the "No known root ..." is insufficient access permissions. Remember that nginx is in control when it launches the LXR scripts. The user-id is either nginx or nobody, which is different from users awal or reshma. Consequently, /home/awal/git/dpdk/.git/ MUST have at least permission $$$$$$r-x (where $ = don't care) or 0$$5.

    Check access permissions with ls -l. Remember also that all directories on the path from the root must also be $$$$$$r-x (i.e. read-able and accessible by everybody).

    Tip:
    If you want to intersperse LXR code with debugging prints, just use Perl's warn() function. I've written (in lib/LXR/Common.pm) a handler for it which displays both on screen and on STDERR (= error log). Moreover, this output is styled through CSS so that it is highlighted on screen.

    Regards,
    ajl

     
  • reshma begam pattan

    Hi Andre,

    We have tried permissions 775 and 777, still didnot see any success.

    Error message that we are seing is triggered from function"makeerrorpage" inside lib/LXR/Template.pm
    Whose defintition clearly says that error will come if URL is incorrect. This doesn't mean URL conversion from nginx to LXR has gone wrong.

    "Function C<makeerrorpage> outputs an HTML error page when an
    incorrect URL has been submitted: no corresponding source-tree
    could be found in the configuration.
    It is primarily aimed at giving feedback to the user."

    Some more tips might be needed here to solve the issue.

    Thanks,
    Reshma

     
  • Andre-Littoz

    Andre-Littoz - 2016-07-04

    Hi Reshma,

    Let's summarise where you are now.

    • nginx is working, LXR is where expected and nginx transfers control to LXR. You can then consider that this part of configuration is correct.
    • http://localhost/ref/LXR_script_name is correctly decoded. This means 'virtroot' in your lxr.conf is understood as expected.
    • The "No known root ..." error page is emitted from initialisation function Common::httpinit() when Config::new(...) has been unable to create a tree-config object comparing data from the URL and lxr.conf .

    Initialisation fails only if function Config::_initialize(...) returns 0, which happens after failure to identify a tree based on "modern" parameters 'host_names', 'virtroot' and eventually 'treename'. There's a fallback for "legacy" parameters but they are not used in your configuration.

    The criteria to match a tree are:

    • Host from URL is compared to lower-cased 'host_names'. I should be stricter and compare lowercased URL-host, but I doubt this is needed in the present case.
    • The script path in the URL is compared to 'virtroot'. The script path comes from server variable SCRIPT_NAME. This variable is synthesised at nginx-lxrserver.conf request with directive
    fastcgi_param SCRIPT_NAME $virtroot$script_name
    

    as a concatenation of two parts of the URL, which should give /ref/source

    From your debugging prints above, it appears that at least the /ref part has not been captured. Can you try to dump $$HTTP{'script_path'} (yes, double $ and uppercase HTTP, lowercase parm name) which is canonised form of the fastCGI parameter.

    $HTTP is a global hash. It can be acessed from anywhere as long as there is a use LXR::Config;
    You can add a warn "FastCGI script name: ", $$HTTP{'script_path'}; in the makeerrorpage() function.

    I've not reinstalled an NginX server here for a while and I can't test that parameter passing has not changed in newer releases.

     

    Last edit: Andre-Littoz 2016-07-04
    • reshma begam pattan

      Hi Andre,

      Here is the requested message.

      Warning
      FastCGI script name: source at /usr/local/share/lxr/lib/LXR/Template.pm line 1758. .

      Thanks,
      Reshma

       

      Last edit: reshma begam pattan 2016-07-08
  • Andre-Littoz

    Andre-Littoz - 2016-07-08

    Hi Reshma,

    Things are narrowing: something must be wrong at last in nginx configuration because the virtual root /ref/ is not present in variable SCRIPT_NAME. There may be an error in a location directive.

    Can you send again nginx-lxrserver.cong making sure it is the copy used with nginx?

    Which is your nginx version?

     
  • reshma begam pattan

    Hi,

    We are using "nginx version: nginx/1.10.0 (Ubuntu)".

    Below files I am sending:
    1) /etc/nginx/sites-enabled/default
    2)/usr/local/share/lxr/custom.d/nginx-lxrserver.conf

     
    • reshma begam pattan

      another file

       
  • Andre-Littoz

    Andre-Littoz - 2016-07-09

    Hi,

    For a reason I don't understand, it seems $virtroot is not set to /ref/ by the regexp in location directives. Try then replacing the variable name by its expected value in the FastCGI parameter definition:

    fastcgi_param SCRIPT_NAME /ref/$scriptname
    

    Keep the warn statement in makeerrorpage() to have debugging printout in case it is still wrong. If it fixes the bug, you'll have the main directory displayed.

    Report here if it fixes your problem. I'll then modify nginx configuration in the wizard: rereading this part of configuration, I see no clear advantage capturing the virtual root in a variable because it is used only once (or rather used locally in an internal block) without being shared with other possible source trees. It might be better to "hardcode" this virtual root (I.e. having it expanded by macro-generation) to avoid this kind of dynamic problem.

    Regards,
    ajl

     
  • reshma begam pattan

    Hi Andre,

    I tried your suggested change still the same issue was seen.
    So I reverted the change and I enabled logging (below in bold) inside "/etc/nginx/sites-available/default" to see what value is copied into below params. They all copied with proper value I guess, see the log output below. if you can make out something out of this let us know. But as of now we will try to reinstall again and see if the problem disappears.

    Params:
    fastcgi_param SERVER_NAME $host;
    fastcgi_param SCRIPT_FILENAME $document_root$script_name;
    fastcgi_param SCRIPT_NAME $virtroot$script_name;
    fastcgi_param PATH_INFO $fastcgi_path_info;
    fastcgi_pass unix:/var/run/fcgiwrap.socket;

    Enable logs:
    error_log /var/log/nginx/error.log debug;
    rewrite_log on;

    Log out put for the params:

    2016/07/15 16:15:13 [debug] 20663#20663: 13 fastcgi param: "SERVER_NAME: 163.33.210.59"
    2016/07/15 16:15:13 [debug] 20663#20663:
    13 fastcgi param: "SCRIPT_FILENAME: /usr/local/share/lxr/source"
    2016/07/15 16:15:13 [debug] 20663#20663: 13 fastcgi param: "SCRIPT_NAME: /ref/source"
    2016/07/15 16:15:13 [debug] 20663#20663:
    13 fastcgi param: "PATH_INFO: "

    Thanks,
    Reshma

     
  • Andre-Littoz

    Andre-Littoz - 2016-07-15

    Hi Reshma,

    All parameters have their correct values. I am puzzled.

    If problem still persists after reinstallation, I'll give you a debugging statement to add to _initialize() function.

    Regards,
    ajl

     
  • reshma begam pattan

    Hi Andre,

    Can you provide the steps for installing LXR on Debian with Nginx.

    Thanks,
    Reshma

     
  • Andre-Littoz

    Andre-Littoz - 2016-08-30

    Hi Reshma,

    The main differrence between Debian and the site or the manual lie in the location (directory) where to put the configuration files. As you noted, the site is Fedora-oriented. There is page in the "Tips" section of http://lxr.sourceforge.net "Ubuntu specifics" (it should rather read "Debian specifics", but people know better Ubuntu than Debian and its off-springs) giving clues on what to do.

    As for Nginx, configuration is handled by the configuration wizard configure-lxr.pl and you should already have the required files. The only "rough" point is Nginx does not support CGI, only FastCGI. Consequently, some interface "glue" is needed. This is explained in the User's Manual. There is a new version of this manual, ready for publication. Send me an e-mail on my SF mailbox ajlittoz (at) users (dot) sourceforge (dot) net (replace the parentheses by the adequate character, without spaces between the address components) and I'll attach the manual in my reply.

    Web server configuration is explained in chapter 7 and section 7.4 is dedicated to Nginx with the necessary run-time environment setup described in 7.4.1.

    I am interested by feed-back about your Debian installation so that I can add a page on the the site and a paragraph (or chapter) in the manual.

    Regards,
    ajl

     

Log in to post a comment.

Want the latest updates on software, tech news, and AI?
Get latest updates about software, tech news, and AI from SourceForge directly in your inbox once a month.